int n=10,aver=0,a=0;
int[]A=new int[n];
console.writeline("输入成绩");
for(i=0;i
A[i]=console.readline();
}
aver=Average(A,n);
for(i=0;i
if(A[i]>aver)
a++;
}
console.writeline("平均分:{0}",aver);
console.writeline("高于平均分人数:{0}",a);
int Average(int[]A,int n)
{
int i,sum=0;
for(i=0;i
sum+=A[i];
}
return sum/n;
}
注:代码没测试过,但也八九不离十了,可作参考
#include
#include
#define N 100
int Average(int A[],int n);
int main()
{
int A[N],aver,n,i,a=0,b=0;
printf("Input n:\n");
scanf("%d",&n);
printf("Input score:\n");
for(i=0;i
scanf("%d",&A[i]);
}
aver=Average(A,n);
printf("Average score is %d\n",aver);
for(i=0;i
if(A[i]>aver)
a++;
else if(A[i]
}
printf("The higher people is %d\n",a);
printf("The lower people is %d\n",b);
return 0;
}
int Average(int A[],int n)
{
int i,sum=0;
for(i=0;i
sum+=A[i];
}
return sum/n;
}
都有内置函数啦