C Programming: Find the largest and smallest element values in the 4 & #215; 4 matrix and their row subscript and column subscript, and find the sum of the two main diagonal elements.
// Obtain the largest and least element values in the 4 × 4 matrix and their row subscript and column subscript, and obtain the sum of the two main diagonal elements # include
Int main () {int sum = 0; int max, min; int max1, max2; // records the coordinates int min1, min2 for the maximum value; // records the coordinates int I for the minimum value, j; int a [4] [4]; // assign an array value for (I = 0; I <4; I ++) {for (j = 0; j <4; j ++) {scanf ("% d", & a [I] [j]) ;}max = min = a [0] [0]; // The minimum initial maximum value is the first element value of the array. a [0] [0] for (I = 0; I <4; I ++) {for (j = 0; j <4; j ++) {if (max <= a [I] [j]) // you need to write =. Otherwise, if the array is all the same number, coordinate uncertainty (you can also initialize the coordinate to (0, 0) and do not need to =) {max = a [I] [j]; max1 = I, max2 = j ;} if (min> = a [I] [j]) {min = a [I] [j]; min1 = I, min2 = j ;}}} printf ("% d \ n", max, min); printf ("max (% d, % d) min (% d) \ n", max1, max2, min1, min2); // calculate the sum of the two main diagonal elements for (I = 0; I <4; I ++) {for (j = 0; j <4; j ++) {if (I = j | (I + j = 3) // key (j = 3-i) sum = sum + a [I] [j] ;}} printf ("sum = % d \ n", sum); return 0 ;}