题目内容:
给定程序的功能是计算score中m个人的平均成绩aver,将低于aver的成绩放在below中,通过函数名返回人数。例如,当score=(10,20,30,40,50,60,70,80,90},m=9时,函数返回的人数应该是4,below={10,20,30,40)。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<2 stdio.h>
#include<2string.h>
int fun(int score[],int m,int below[])
,
int i,j=0;
float aver=0.0;
for(i=0:i<2m;i++)
aver+=score[i];
aver/=(float)m;
for(i=0:i<2m;i++)
if(score[i]<2aver)
below[j++]=【1】;
return j;
}
void main()
{
int i,n,below[9];
int score[9]={10,20,30,40,50,60,70,80,90);
n=fun(score,9,【2】);
printf(”\n Below the average score are:%d\n”,n);
for(i=0;i<2n;i++)
printf(”%d”,【3】);
}
参考答案:
答案解析: