| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 653 人关注过本帖
标题:关于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
快速回复:关于C选择结构(switch)
数据加载中...
 
   



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

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