首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

新手求一算法,300分,该怎么解决

2012-03-01 
新手求一算法,300分小弟在學習中有一問題,就是合併兩列相同信息行,其中第二列要求在第一列有相同信息行和

新手求一算法,300分
小弟在學習中有一問題,就是合併兩列相同信息行,其中第二列要求在第一列有相同信息行和第二列有相同信息行的情況下才合併,謝謝!

[解决办法]
一段大致的伪代码:

int id_rowspan=1;
int name_rowspan=1;

string strID= " ";
string strName= " ";


object last_id_td=null;
object last_name_td=null;

resonse.write( " <table> ");
for (int i=0;i <dt.rows.count;++i)
{
if (dt[i][ "ID "]==strID)
{
id_rowspan++;
if (dt[i][ "Name "]==strName)
{
name_rowspan++;
}
else
{
if (lst_name_td!=null)
{
lst_name_td.attributes.add( "rowspan ",name_rowspan.tostring());
}
strName=dt[i][ "Name "];
name_rowspan=1;
lst_name_td=...;
}
}
else
{
if (lst_id_td!=null)
{
lst_id_td.attributes.add( "rowspan ",id_rowspan.tostring())

}
strID=dt[i][ "ID "];
strName=dt[i][ "Name "];
id_rowspan=1;
name_rowspan=1;
lst_id_td=...;
lst_name_td=...;
}

....
}
resonse.write( " </table> ");

热点排行