C语言编程题如下,编制程序从10个学生的成绩中统计出高于或等于平均分的人数?

2024-11-24 11:57:03
推荐回答(1个)
回答1:

#include

const int n = 10;

int main()
{
int i, sum = 0, ave, count = 0;
int a[n];

printf("请输入%d个正整数:\n", n);

for (i = 0; i < n; i++)
scanf("%d", &a[i]);

for (i = 0; i < n; i++)
sum += a[i];

ave = sum / n;

for (i = 0; i < n; i++)
if (a[i] > ave)
count++;

printf("大于平均分的人数是 %d\n", count);

return 0;
}