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

2024-11-18 18:32:01
推荐回答(1个)
回答1:

# include
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);

}