#include
int main()
{
float a[10],min,max;
int i;
printf("please enter 10 num\n");
for(i=0;i<10;i++)
{
scanf("%f",&a[i]);
}//输入
min=max=a[0];
//假设第一个数是最小的数,且是最大数
for(i=1;i<10;i++)
{
//依次与其它各数比较
if(a[i]>max)
{
max=a[i];
}
else if(a[i]
min=a[i];
}
}
printf("\nmax is %f min is %f\n",max,min);
}
假设数组是a,有n个元素
int max = -1;
int min = 10000000;
for (int i = 0;i
if (a[i]>max)
max = a[i];
if (a[i]
}
printf ("max is %d min is %d",max,min);