/**:用二重循环求出二维数组 b 所有元素的和:
int[][] b={{11},{21,22},{31,32,33}}
*/
public class Zy05_5{
int sum;
public int Zy05_5(){
int[][] b={{11},{21,22},{31,32,33}};
for(int row = 0;row < 3; row ++){
for(int col = 0;col <= row;col ++ ){
System.out.println(b[row][col]);
sum += b[row][col];
}
}return sum;
}
public static void main(String args []){
Zy05_5 show = new Zy05_5();
int s = show.Zy05_5();
System.out.println(s);
}
}
求二位数组所有元素之和
最新推荐文章于 2023-04-04 11:27:32 发布