java问题,谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/05 14:25:56
问题是这样的,下面有2个for循环, 当j循环时相当于每行从t1,t2一直到t5,i循环时相当于下面7行,从第1行到第7行,想根据这样的循环把括号里的值一一赋给x,y,如何操作啊
1:t1(2,1)t2(3,2)t3(4,3)t4(5,4)t5(6,5) 2:t1(1,2)t2(2,3)t3(3,4)t4(4,5)t5(5,6) 3:t1(1,0)t2(1,0)t3(1,0)t4(1,0)t5(1,0) 4:t1(1,1)t2(2,2)t3(3,3)t4(4,4)t5(5,5) 5:t1(1,3)t2(2,4)t3(3,1)t4(4,6)t5(5,7) 6:t1(0,1)t2(2,1)t3(2,4)t4(2,5)t5(3,5) 7:t1(3,1)t2(1,3)t3(3,2)t4(3,5)t5(4,5)

for(int j = 0; j < 5; j++) {
for(int i = 0; i < 7; i++) {
int x =
int y =

是我这个答案么?

public class ZZZZZ {

/**
* @param args
*/
public static void main(String[] args) {
int[][][] intarr = {
{{2,1}, {3,4}, {5,6}, {7,8}, {9,0}},
{{22,1}, {3,4}, {5,6}, {7,8}, {9,0}},
{{32,1}, {3,4}, {5,6}, {7,8}, {9,0}},
{{42,1}, {3,4}, {5,6}, {7,8}, {9,0}},
{{52,1}, {3,4}, {5,6}, {7,8}, {9,0}},
{{62,1}, {3,4}, {5,6}, {7,8}, {9,0}},
{{72,1}, {3,4}, {5,6}, {7,8}, {9,0}},
};

for (int i = 0; i < intarr.length; i++) {
for (int j = 0; j < intarr[i].length; j++) {
int x = intarr[i][j][0];
int y = intarr[i][j][1];
System.out.print("| x=" + x + ", y=" + y);
}
System.out.println("");
}

}
}

1:t1(2,1)t2(3,2)t3(4,3)t4(5,4)t5(6,5)
2:t1(1,2)t2(2,3)t3(3,4)t4(4,5)t5(5,6)
3:t1(1,0)t2(1,0)t3(1,0)t4(1,0)t5(1,0)
4:t1(1,1)t2(2,2)t3(3,3)t4