2025-03-04 22:18:35 +08:00

28 lines
535 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
功能找出n个数中最大的数和最小的数并将它们的值输出出来。
--------------------------------------------------------*/
#include<stdio.h>
int main()
{
int a,n,i,min,max;
scanf("%d",&n);
scanf("%d",&a);
min=a;
max=a;
for(i=1;i<n;i++)
{
/**********Program**********/
scanf("%d", &a);
if(a > max){
max = a;
}
if(a < min){
min = a;
}
/********** End **********/
}
printf("The maximum number is %d.\n",max);
printf("The minimum number is %d.\n",min);
}