S suguangyi Unregistered / Unconfirmed GUEST, unregistred user! 2003-10-11 #1 把两个3*3数组中相应位子的数相加,结果存到第三个3*3数组,如 3 2 4 1 0 0 2 2 4 2 5 2 = 0 1 0 + 2 4 2 4 2 3 0 0 1 4 2 2
Z ZRWeng Unregistered / Unconfirmed GUEST, unregistred user! 2003-10-11 #3 你说的是二维而已,不是三维 public class Demo{ public static void main(String[] args){ int[][] arrayOne={{1,0,0}, {0,1,0}, {0,0,1}}; int[][] arrayTwo={{2,2,4}, {2,4,2}, {4,2,2}}; int[][] result=new int[3][3]; for(int i=0;i<result.length;i++){ for(int j=0;j<result.length;j++){ result[j]=arrayOne[j]+arrayTwo[j]; System.out.print(result[j]+" "); } System.out.println(); } } }
你说的是二维而已,不是三维 public class Demo{ public static void main(String[] args){ int[][] arrayOne={{1,0,0}, {0,1,0}, {0,0,1}}; int[][] arrayTwo={{2,2,4}, {2,4,2}, {4,2,2}}; int[][] result=new int[3][3]; for(int i=0;i<result.length;i++){ for(int j=0;j<result.length;j++){ result[j]=arrayOne[j]+arrayTwo[j]; System.out.print(result[j]+" "); } System.out.println(); } } }