C语言编程,函数
#include <stdio.h>
float max(float a[])
{
int i;
float m = a[0];
for(i=1;i<10;i++)
{
if(m<a[i])
m = a[i];
}
return m;
}
float min(float a[])
{
int i;
float m = a[0];
for(i=1;i<10;i++)
{
if(m>a[i])
m = a[i];
}
return m;
}
float aver(float a[])
{
float sum = 0;
int i;
for(i=0;i<10;i++)
sum += a[i];
return sum / 10;
}
int main()
{
float num[10];
int i;
for(i=0;i<10;i++)
scanf("%f",&num[i]);
printf("The max number is %f\n",max(num));
printf("The min number is %f\n",min(num));
printf("The average number is %f\n",aver(num));
return 0;
}