标题:关于C选择结构(switch)
取消只看楼主
maoxiaojian
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-9-1
结帖率:0
已结贴  问题点数:20 回复次数:0 
关于C选择结构(switch)
请高手帮忙看一下下面的程序哪里错了:
#include<stdio.h>
int main()
{
float score;
char grade;
printf("please printf your score:");
scanf("%f",&score);
while(score>100||score<0)
{
printf("\nprintf is wrong,please printf again");
scanf("%f",&score);
}
switch((int)(score/10))
{
case10:
case9:grade='A';break;
case8:grade='B';break;
case7:grade='C';break;
case6:grade='D';break;
case5:
case4:
case3:
case2:
case1:
case0:grade='E';
}
printf("the score is %5.1f,the grade is %c\n",score,grade);
return 0;
}
(不考虑英语语法错误)
输入56
运行结果是:
the score is 56.0,the grade is
也就是说运行结果没有输出等级,怎么回事呢?



搜索更多相关主题的帖子: return please include 结构 
2012-09-09 21:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-381053-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.322139 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved