12.输入一个成绩计算其A,B,C,D,E等级

复制代码
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <math.h>
 4 int main()
 5 {
 6     int score;
 7     scanf("%d",&score);
 8     if(score>100||score<0)
 9     {
10         printf("输入错误,请重新输入:");
11         scanf("%d",&score);
12     }
13     switch((int)score/10)   //分数整除后强制转换为整数
14     {
15         case 10:
16         case 9: printf("grade = A"); break;
17         case 8: printf("grade = B"); break;
18         case 7: printf("grade = C"); break;
19         case 6: printf("grade = D"); break;
20         case 5:
21         case 4:
22         case 3:
23         case 2:
24         case 1:
25         case 0: printf("grade = E"); break;
26 
27     }
28 
29     return 0;
30 }
复制代码

 

posted @   小孢子  阅读(334)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示