package zuoye; public class zuoye0110 { public static void main(String[] args) { // TODO 自动生成的方法存根 //遍历二维数组 int[][]a={{12,23,45,78,43},{97,435,78,9,45,423},{45,7,4,32}}; int sum =0; for(int b=0;b<a.length;b++){ for(int c=0;c<a[b].length-1;c++){ sum+=a[b][c]; System.out.print(a[b][c]+" "); }System.out.println(); }System.out.println("所有元素的和是:"+sum); }}
时间: 2024-10-06 01:22:42