data[1] ? data[1] : data[0]; min2 = data[0]>data[1] ? data[0] : data[ 1]; for(i = 2; i " />
Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Enter the value of a one-dimensional integer array from the keyboard (array size is 10), and find the minimum number min1 and the subminimum number min2 in the array
Enter the value of a one-dimensional integer array from the keyboard (array size is 10), and find the minimum number min1 and the subminimum number min2 in the array

#include

int main(void)

{

int i, min1, min2, data[ 10] = {0};

for(i = 0; i < 10; i++)

scanf("%d", data+i);

< p>min1 = data[0]>data[1] ? data[1] : data[0];

min2 = data[0]>data[1] ? data[0] : data[ 1];

for(i = 2; i < 10; i++)

{

if(data[i] < min1)

{

min2 = min1;

min1 = data[i];

}

else if(data[i ] < min2)//Assume that the sub-minimum number is allowed to be equal to the minimum number

min2 = data[i];

}

printf("min1 = % d, min2 = %d\n", min1, min2);

getch();

return 0;

}