将百分制成绩转换为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" 程序示例运行1如下: input the score :90 score=90-->A 程序示例运行2如下: input the score :50 score=50-->E
时间: 2024-03-06 17:46:29 浏览: 238
以下是一个 Python 程序,可以实现您的要求:
```python
score = int(input("input the score :"))
if score < 0 or score > 100:
print("score=%d is error!\n" % score)
elif score >= 90:
print("score=%d-->A\n" % score)
elif score >= 80:
print("score=%d-->B\n" % score)
elif score >= 70:
print("score=%d-->C\n" % score)
elif score >= 60:
print("score=%d-->D\n" % score)
else:
print("score=%d-->E\n" % score)
```
程序使用 `input` 函数从键盘读入一个整数 `score`,然后使用 `if-elif-else` 语句判断 `score` 所对应的等级,并输出相应的提示信息。
请注意,上述程序中的 `%d` 是格式控制符,用于指定在输出整数时的格式。`if-elif-else` 语句是 Python 中的条件语句,用于根据不同的条件执行不同的代码块。
相关问题
将百分制成绩转换为abcde五个等级
将百分制成绩转换为abcde五个等级,通常是按照以下标准进行转换:
A:90分及以上
B:80-89分
C:70-79分
D:60-69分
E:60分以下
根据这个标准,可以将百分制成绩转换为相应的等级,方便进行评估和比较。
将百分制成绩转换为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"
好的,以下是对应的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;
}
```
希望能对你有所帮助!
阅读全文
相关推荐















