解题思路:
注意事项:
while(score!=0&&score!=-1)
{
scanf("%f",&score);
if(score>=85) count1++;
else if (score>=60) count2++;
else if (score!=0&&score!=-1) count3++;
}
注意不要使输入的-1或者0 被统计其中
参考代码:
#include <stdio.h> int main() { float score=1; int count1=0,count2=0,count3=0; while(score!=0&&score!=-1) { scanf("%f",&score); if(score>=85) count1++; else if (score>=60) count2++; else if (score!=0&&score!=-1) count3++; } printf(">=85:%d\n",count1); printf("60-84:%d\n",count2); printf("<60:%d\n",count3); return 0; }
0.0分
0 人评分
点我有惊喜!你懂得!浏览:1074 |
【C语言训练】谁家孩子跑最慢* (C语言代码)浏览:1302 |
母牛的故事 (C语言代码)浏览:515 |
C语言考试练习题_保留字母 (C语言代码)浏览:473 |
字符串输入输出函数 (C++代码)(都当成字符串吧hhhhhhhh)浏览:404 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:358 |
不容易系列2 (C语言代码)浏览:493 |
多输入输出练习1 (C语言代码)浏览:993 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:559 |
C语言程序设计教程(第三版)课后习题8.2 (C语言代码)浏览:4747 |