日期:2014-05-20 浏览次数:20659 次
int[][] a = { {69,89,109,139,169,189}, {100,120,140,160,180,200} }; int[][] b = new int[a[0].length][a.length]; for (int i=0; i<a.length; i++) { for (int j=0; j<a[i].length; j++) { b[j][i] = a[i][j]; } } for (int[] t : b) { System.out.println(Arrays.toString(t)); }
------解决方案--------------------
private static void test() { int[] a = {69,89,109,139,169,189}; int[] b = {100,120,140,160,180,200}; for(int i=0;i<a.length;i++){ for(int j=0;j<b.length;j++){ if(i==j){ System.out.println(a[i]+" "+b[j]); break; } } } }