急求高手帮忙解决问题。。。(C语言编写程序题)急啊!万分谢谢!

上海世博会在“十一”黄金周7天中,每天的参观人数如下表所示。编写程序:统计7天共接待了多少参观人数? 平均每天多少人?高于平均数的有几天?

日期 10月1日 10月2日 10月3日 10月4日 10月5日 10月6日 10月7日
人数/万 25.40 39.18 44.75 43.13 43.21 29.84 21.92

# include<stdio.h>
float s(float *p,int n)
{ int i;
float s=0.;
for(i=0;i<7;i++,p++)
{s=s+*p;}
return s;
}
void main()
{ float a[7]={25.40,39.18,44.75,43.13,43.21,29.84,21.92};
float ave,sum;
int i,n=0;
sum=s(a,7);
printf("7天共接待参观人数为%.2f万人\n",sum);
ave=sum/7;
printf("平均每天接待%.2f万人\n",ave);
for(i=0;i<7;i++)
{if(a[i]>ave) n++;}
printf("高于平均数的有%d天\n",n);

}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答