3.一个班级有20名学生,从键盘输入所有学生的英语考试成绩,求出全班该门课程的平均成绩.
1个回答

#include

#include

#define NUM 20

int main()

{

int scores[NUM];

printf("Please enter English scores:n");

for ( int i = 0; i < NUM; i++)

{

printf("%d:",i+1);

scanf("%d",&scores[i]);

}

int total = 0;

int _90 = 0;

int _60 = 0;

for ( int i = 0; i < NUM; i++ )

{

total += scores[i];

if( scores[i] >= 90 )

_90++;

else if( scores[i] < 60 )

_60++;

}

printf("Average scores:%.2fn 90+=%dn 60-=%d",(float)total/NUM,_90,_60);

return 0;

}