二维数组的遍历,求和
int [] [] s = {{1,2,3,4},{5,6,7,8,3,3},{9,10,11,12}};
int sum=0;
for (int i = 0; i < s.length; i++) {
for (int j = 0; j < s[i].length; j++) {
sum+=s[i][j];
}
}
System.out.println(sum);
Console:84;
原文地址:https://www.cnblogs.com/fengxia/p/10202549.html
时间: 2024-10-13 10:17:44