C语言题目

[复制链接]
查看11 | 回复4 | 2006-11-3 20:02:24 | 显示全部楼层 |阅读模式
用VB做更简单
回复

使用道具 举报

千问 | 2006-11-3 20:02:24 | 显示全部楼层
用case 语句做啦`````
回复

使用道具 举报

千问 | 2006-11-3 20:02:24 | 显示全部楼层
用的是switch--case语句做的:#include int main(void) {
int score,count;
printf("Input a number please:\n");
scanf("%d",&score);
count=(int)(score-5)/10; switch(count){
case 9: printf("Your score is A\n"); break;case 8: printf("Your score is B\n"); break;case 7: printf("Your score is C\n"); break;
default: printf("Your score is D\n"); break; }
return 0;}一下是部分测试结果:(1)Input a number please:95Your score is APress any key to continue(2)Input a number please:94Your score is BPress any key to continue(3)Input a number please:74Your score is DPress any key to continue
回复

使用道具 举报

千问 | 2006-11-3 20:02:24 | 显示全部楼层
谭浩强教材中的例题呀
回复

使用道具 举报

千问 | 2006-11-3 20:02:24 | 显示全部楼层
#include main(){int score;char grade;printf("please input score:");scanf("%d",&score);if(score>=0&&score=95) grade='A';else if (score>=85) grade='B';else if (score>=75) grade='C';else grade='D';printf("grade is %c",grade);}else printf("error");}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行