[AppleScript] 纯文本查看 复制代码
public class Tr_2 {
public static void main(String[] args) {
int[][] arr = {{1,2,3},{2,2,3},{3,0,4,3}};
int[] array = new int[arr.length];
int max = 0;
int index =0;
for (int i = 0;i<array.length;i++) {
array = 0;
for (int j = 0;j < arr.length;j++) {
array += arr[j];
}
if(max < array) {
max = array;
index = i;
}
}
StringBuffer sb = new StringBuffer(" 一维数组:{");
for (int i = 0; i < arr[index].length; i++) {
if(i==arr[index].length-1) {
sb.append(arr[index]).append("}");
}else {
sb.append(arr[index]).append(",");
}
}
System.out.println("最大值:"+ max + sb.toString());
}
}