m个人的成绩放在score数组中,函数fun的功能是:将低于平均分的人数作为函数值返回,将低于平均分的分数放在below所指的数组中。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
int fun(int score[], int m, int below[])
{
int i = 0, j = 0;
double ave = 0;
for (i = 0;i < m;i++)
ave += score[i];
ave = ave / m;
for (i = 0;i < m;i++)
if (ave >= score[i])
{
below[j] = score[i];
j++;
}
return j;
}
int main()
{
int i, n, below[9];
int score[9] = { 10,20,30,40,50,60,70,80,90 };
n = fun(score, 9, below);
printf("\nBelow the average score are:\n");
for (i = 0;i < n;i++)
printf(" %d ", below[i]);
system("pause");
return 0;
}