
C语言:在score数组存放有m个成绩,在函数fun中计算平均分,再将低于平均分的人数作为函数值返回,
并将低于平均分的分数存放在below数组中,最后在main函数中输出below数组。例如,score数组的数据为85,78,64,90,70,82时,函数返回的人数应该是...
并将低于平均分的分数存放在below数组中,最后在main函数中输出below数组。
例如,score数组的数据为85, 78, 64, 90, 70, 82时,函数返回的人数应该是“3”,below数组中的数据应为“78, 64, 70”。 展开
例如,score数组的数据为85, 78, 64, 90, 70, 82时,函数返回的人数应该是“3”,below数组中的数据应为“78, 64, 70”。 展开
2个回答
展开全部
#include <stdio.h>
#define m 6
int fun(int score[],int below[])
{
int aver,sum=0,count=0,i;
for(i=0; i<m; i++)
sum += score[i];
aver = sum/m;
for(i=0; i<m; 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<a; i++)
printf("% d", below[i]);
printf("\n");
printf("%d\n",a);
return 0;
}
#define m 6
int fun(int score[],int below[])
{
int aver,sum=0,count=0,i;
for(i=0; i<m; i++)
sum += score[i];
aver = sum/m;
for(i=0; i<m; 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<a; i++)
printf("% d", below[i]);
printf("\n");
printf("%d\n",a);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询