从44,5,6,13,35,787,90,67,2,34十个数中找出最大值,最小值,求平均值,并输出
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[10],i,zd,zx,he;
float pj;
a[10]={44,5,6,13,35,787,90,67,2,34}
zd=a[0];
zx=a[0];
he=0;
for (i=0;i<10;i++)
{
if(zd<a[i]) zd=a[i];
if(zx>a[i]) zx=a[i];
he=he+a[i];
}
pj=he/20;
printf("最大值%d最小值%d平均值%f",zd,zx,pj);
system("pause");
return 0;
}
|