class Demo02 { public static void main(String[] args) { /*int[] arr = new int[3]; System.out.println(arr); System.out.println(arr.length); System.out.println(arr[0]); System.out.println(arr[1]); System.out.println(arr[2]); //给元素赋值 arr[0] = 100; arr[1] = 200; arr[2] = 300; System.out.println(arr[0]); System.out.println(arr[1]); System.out.println(arr[2]); int[] arr2 = {11,12,13}; int[] arr3 = new int[]{11,12,13}; //数组遍历 for(int i = 0;i<arr.length;i++){ System.out.println(arr[i]); }*/ //数组最大值 int[] arr = {55,66,11,99,44,33,22}; int max = arr[0]; for(int i = 1;i<arr.length;i++){ if(arr[i]>max){ max = arr[i]; } } System.out.println(max); } }
class Demo05 { public static void main(String[] args) { /*int[][] arr = new int[2][4]; //二维数组遍历 for(int i = 0;i<arr.length;i++){ for(int j = 0;j<arr[i].length;j++){ System.out.println(arr[i][j]); } } //二维数组求和 int sum = 0; for(int i = 0;i<arr.length;i++){ for(int j = 0;j<arr[i].length;j++){ sum+=arr[i][j]; } } System.out.println(sum);*/ //求总销售额和各个季度销售额 /*int[][] arr = {{11,12},{21,22,23},{31,32,33,34}}; int sum1 = 0; int sum = 0; for(int i = 0;i<arr.length;i++){ for(int j = 0;j<arr[i].length;j++){ sum +=arr[i][j]; sum1 +=arr[i][j]; } System.out.println(sum1); sum1 = 0; } System.out.println(sum);*/ } }