假設列名是C1,C2,C3,C4,C5。
僞代碼/算法。
int C1_MaxValue, C2_MaxValue, C3_MaxValue, C4_MaxValue, C5_MaxValue;
string C1_Row, C2_Row, C3_Row, C4_Row, C5_Row;
//Initialize row1 values as max values.
C1_MaxValue = DataTable.Rows[1]["C1"];
C2_MaxValue = DataTable.Rows[1]["C2"];
C3_MaxValue = DataTable.Rows[1]["C3"];
C4_MaxValue = DataTable.Rows[1]["C4"];
C5_MaxValue = DataTable.Rows[1]["C5"];
//Set R1 as row for max values.
C1_Row = C2_Row = C3_Row = C4_Row = C5_Row = DataTable.Rows[1][Row1];
For (i=2 to RowCount -1)
if(Datatable.Rows[i]["C1"] > C1_MaxValue)
{
C1_MaxValue = Datatable.Rows[i][C1];
C1_Row = Datatable.Rows[i][0];
}
//Do the above for all other columns.
End For
在上述變量的末尾,應包含最大值和相應的最大行數。