将百分制成绩转换为ABCDE五个等级(假设成绩都为整数值)。成绩范围为[0,100]. 相应等级为[90,100]是A,[80,90)是B,[70,80)是C,[60,70)是D,60以下为E **输入格式要求:"%d" 提示信息:"input the score :" **输出格式要求: 范围错误"score=%d is error!\n" 范围正确输出相应等级"score=%d-->A\n"
时间: 2024-02-16 18:59:40 浏览: 190
将成绩划分为5个等级,并从键盘输入一个成绩,判断其等级并输出\
5星 · 资源好评率100%
好的,以下是对应的C语言代码:
```c
#include <stdio.h>
int main() {
int score;
printf("input the score :");
scanf("%d", &score);
// 判断成绩范围并输出相应等级
if (score >= 0 && score <= 100) {
if (score >= 90 && score <= 100) {
printf("score=%d-->A\n", score);
} else if (score >= 80 && score < 90) {
printf("score=%d-->B\n", score);
} else if (score >= 70 && score < 80) {
printf("score=%d-->C\n", score);
} else if (score >= 60 && score < 70) {
printf("score=%d-->D\n", score);
} else {
printf("score=%d-->E\n", score);
}
} else {
printf("score=%d is error!\n", score);
}
return 0;
}
```
希望能对你有所帮助!
阅读全文