Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Enter a 3x4 matrix of int numbers and find the maximum and minimum values (using a two-dimensional array).
Enter a 3x4 matrix of int numbers and find the maximum and minimum values (using a two-dimensional array).
# include & ltstdio.h & gt

void main()

{

int a[3][4]; //Define an array

for(int I = 0; I<3; I++) // Input array

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

{

scanf("%d ",& ampa[I][j]);

};

Int max, min// defines the maximum and minimum values.

max = a[0][0]& gt; a[0][ 1]? a[0][0]:a[0][ 1]; //Let the maximum value be the greater of a[0][0] and a[0][ 1] at first.

min = a[0][0]+a[0][ 1]-max; //As above, it is a small number.

for(int x = 0; x & lt3; X++) // Find the maximum value

for(int y = 2; y & lt4; y++)

{

max = max & gta[x][y]? max:a[x][y]; //If it is greater than max, assign it to max.

};

for(int x 1 = 0; x 1 & lt; 3; X 1++) // ditto

for(int y 1 = 2; y 1 & lt; 4; y 1++)

{

min = min & lta[x 1][y 1]? min:a[x 1][y 1];

}

printf("max = %d\n ",max);

printf("min = %d ",min);

}