Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language programming test: It is known that a[4][4] is a plastic array, and the largest element on two diagonal lines and its position are found by programming.
C language programming test: It is known that a[4][4] is a plastic array, and the largest element on two diagonal lines and its position are found by programming.
# include & ltstdio.h & gt

int main()

{

int a[4][4]={0, 1,2,3,4,5,6,7,8,9, 10, 1 12, 13, 14, 15 };

int i,j,m=0,n=0,max = a[0][0];

for(I = 0; I<4; i++)

for(j = 0; j & lt4; j++)

{

if(i==j||i+j==3)

if(a[I][j]& gt; Max)

{

max = a[I][j];

m = I;

n = j;

}

}

printf("m=%d n=%d max=%d\n ",m,n,max); //m represents rows, n represents columns, and max represents the maximum value.

Returns 0;

}