用C语言,输入一个班10个学生的成绩,统计各分数段[0,60),[60,70),[70,80),[80,90),[90-100]的人数。

如题所述

这个是你要的程序,vc6.0通过调试运行了。
#include<stdio.h>
void main()
{
int no=1,count[5]={0,0,0,0,0};
float score;
for(;no<=10;no++)
{
printf("input a score:\n");
scanf("%f",&score);
if(score>=0&&score<60)
count[0]++;
if(score>=60&&score<70)
count[1]++;
if(score>=70&&score<80)
count[2]++;
if(score>=80&&score<90)
count[3]++;
if(score>=90&&score<=100)
count[4]++;
}
printf("0~60:%d\n60~70:%d\n70~80:%d\n80~90:%d\n90~100:%d\n",count[0],count[1],count[2],count[3],count[4]);
}
温馨提示:答案为网友推荐,仅供参考
相似回答