日期:2014-05-18  浏览次数:20575 次

请问怎样得到这个结果
初始值:
line count serial
1 2 22
1 3 23
2 7 24

要得到的结果:
1 1 22
1 2 22
1 3 23
1 4 23
1 5 23
2 1 24
2 2 24
2 3 24
2 4 24
2 5 24
2 6 24
2 7 24

------解决方案--------------------
怎么不是1,2,3 而是12345
------解决方案--------------------

public class Test2 {

public static void main(String sts[]) {
int data[][] = { { 1, 2, 22 }, { 1, 3, 23 }, { 2, 7, 24 } };
int rows = data.length;
for (int i = 0; i < rows; i++) {
if (0 == i || (data[i][0] != data[i - 1][0])) {
for (int j = 0; j < data[i][1]; j++) {
System.out.print(data[i][0]);
System.out.print(" ");
System.out.print(j + 1);
System.out.print(" ");
System.out.println(data[i][2]);
}
} else {
int temp = data[i - 1][1] + data[i][1];
for (int j = data[i - 1][1]; j < temp; j++) {
System.out.print(data[i][0]);
System.out.print(" ");
System.out.print(j + 1);
System.out.print(" ");
System.out.println(data[i][2]);
}
}
}
}
}