您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

c语言输入成绩怎么判断等级

2025/11/22 2:25:24发布17次查看
判断方法:1、用“switch(成绩/10){case 9:a;..case 6:d;default:e;}”语句;2、用“if(成绩>=90)a;else if(成绩>=80)b;..else if(成绩>=60)d;elsee;”语句。
本教程操作环境:windows7系统、c99版本、dell g3电脑。
分析:我们既可以使用else if来进行判断也可以使用switch case来进行判断。
题目要求如下:输入学生成绩,自动判断等级
成绩等级
90<=score<=100 a等级
80<=score<90 b等级
70<=score<80 c等级
60<=score<70 d等级
0 c语言中输入成绩后自动判断等级功能的两种实现方式使用switch...case语句判断等级
使用else if语句
1、使用switch…case语句判断等级
#include <stdio.h>int main(){ int i; scanf("%d",&i); i/=10; switch(i){ case 9: printf("a"); break; case 8: printf("b"); break; case 7: printf("c"); break; case 6: printf("d"); break; default: printf("e"); break; } return 0; }
运行结果
2、使用if..else..if语句
#include <stdio.h>int main(){ int score; scanf("%d",&score); if(score>=90)printf("a"); else if(score>=80)printf("b"); else if(score>=70)printf("c"); else if(score>=60)printf("d"); else printf("e"); return 0; }
运行结果
相关推荐:《c语言视频教程》
以上就是c语言输入成绩怎么判断等级的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product