#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, const char *argv[])
{
//输入一个数组arr,存入5个数,求最大最小值,平均值,求和
int arr[5];
int i;
int max=0;
int min;
int sum=0;
float avg;
for(i=0;i<5;i++)
{
printf("请存入第%d项数",i+1);
scanf("%d",&arr[i]);
}
min=arr[0];
for(i=0;i<5;i++)
{
if(max<=arr[i])
{
max=arr[i];
}
else if(min>arr[i])
{
min=arr[i];
}
}
printf("max = %d\n",max);
printf("min = %d\n",min);
for(i=0;i<5;i++)
{
sum=sum+arr[i];
avg=(float)sum/5;
}
printf("sum = %d\n",sum);
printf("avg = %.2f\n",avg);
return 0;
}
01-02