小白求大神解答
C语言题目:输入n个学生的成绩,求其平均分,并统计超过平均分的学生人数。(n由键盘输入),只会求平均分,再加上统计人数又不知道该咋弄了,求解呀
程序代码:
#include <stdio.h> #include <stdlib.h> #define MAX 100 int main() { int score[MAX]={0}; int i,n; printf("How many students are there:"); scanf("%d",&n); printf("Input %d scores,split by blank or enter:\n",n); float sum=0,ave; for(i=0;i<n;i++) { scanf("%d",&score[i]); sum+=score[i]; } ave=sum/n; int count=0; for(i=0;i<n;i++) { if(score[i]>ave) count++; } printf("Ave=%.2f,and there is %d scores > ave.\n",ave,count); return 0; }