![](https://csdnimg.cn/release/download_crawler_static/86633226/bg1.jpg)
2010 二级 C 语言南开 100 题
1: 第 1 题 m 个人的成绩存放在 score 数组中,请编写函数 fun,它的功能是:将
低于平均分的人作为函数值返回,将低于平均分的分数放在 below 所指定的函
数中。
答案:
int fun(int score[],int m,int below[])
{
int i,k=0,aver=0;
for(i=0;i<m;i++)
aver+=score[i];
aver/=m;
for(i=0;i<m;i++)
if(score[i]<aver)
{
below[k]=score[i];
k++;
}
return k;
}
2: 第 2 题 请编写函数 fun,它的功能是:求出 1 到 100 之内能北 7 或者 11 整除,
但不能同时北 7 和 11 整除的所有证书,并将他们放在 a 所指的数组中,通过 n
返回这些数的个数。
答案:
void fun(int *a, int *n)
{
int i,j=0;
for(i=2;i<1000;i++)
if ((i%7==0 || i%11==0) && i%77!=0)
a[j++]=i;
*n=j;
}