用c语言键盘输入一个百分制成绩score整数且0≤score≤100要求输出成绩等级A、B、C、D、E。90≤score≤100时为A’80≤score≤89时输出B’70≤score≤79时输出C’60≤score≤69时输出D’0≤score60时输出E’score0或score100时输出输入成绩有误!。
#include <stdio.h>
int main() {
int score;
printf("请输入成绩:");
scanf("%d", &score);
if (score >= 90 && score <= 100) {
printf("成绩等级为:A\n");
} else if (score >= 80 && score <= 89) {
printf("成绩等级为:B\n");
} else if (score >= 70 && score <= 79) {
printf("成绩等级为:C\n");
} else if (score >= 60 && score <= 69) {
printf("成绩等级为:D\n");
} else if (score >= 0 && score < 60) {
printf("成绩等级为:E\n");
} else {
printf("输入成绩有误!\n");
}
return 0;
}
原文地址: https://www.cveoy.top/t/topic/bT21 著作权归作者所有。请勿转载和采集!