C语言:在score数组存放有m个成绩,在函数fun中计算平均分,再将低于平均分的人数作为函数值返回,

2024-10-29 17:33:50
推荐回答(2个)
回答(1):

#include
#define m 6
int fun(int score[],int below[])
{
int aver,sum=0,count=0,i;
for(i=0; i sum += score[i];
aver = sum/m;
for(i=0; i if(score[i] <= aver)
below[count++] = score[i];
return count;
}
int main(void)
{
int score[m] = {85,78,64,90,70,82};
int below[m],i;
int a;
a = fun(score,below);
for(i=0; i printf("% d", below[i]);
printf("\n");
printf("%d\n",a);
return 0;
}

回答(2):

if(m<100){逐个比较,计数}else{类桶排序计数}return count;