发布网友 发布时间:2022-04-22 10:07
共3个回答
热心网友 时间:2023-10-31 19:46
#include <stdio.h>
int main()
{
int score, m;
scanf("%d", &score);
while (score < 0 || score > 100){
printf("Error! Retry!\n");
scanf("%d", &score);
}
m= score / 10;
if (m>= 9)
printf("Grade is A!\n");
switch(m){
case 0: printf("Grade is E!\n"); break;
case 1: printf("Grade is E!\n"); break;
case 2: printf("Grade is E!\n"); break;
case 3: printf("Grade is E!\n"); break;
case 4: printf("Grade is E!\n"); break;
case 5: printf("Grade is E!\n"); break;
case 6: printf("Grade is D!\n"); break;
case 7: printf("Grade is C!\n"); break;
case 8: printf("Grade is B!\n"); break;
}
return 0;
}
扩展资料:
其他实现输出成绩等级‘A'、’B‘、'C'、‘D'、'E’。90分以上为A,80~分为B,70~79分为C,60~69分为D,60分一下为E的方法:
#include <stdio.h>
int main()
{
int score;
scanf("%d", &score);
while (score < 0 || score >100){
printf("Error! Retry!\n");
scanf("%d", &score);
}
if (score < 60)
printf("Grade is E!\n");
else if (score >= 60 && score < 70)
printf("Grade is D!\n");
else if (score >= 70 && score < 80)
printf("Grade is C!\n");
else if (score >=80 && score < 90)
printf("Grade is B!\n");
else
printf("Grade is A!\n");
return 0;
}
热心网友 时间:2023-10-31 19:47
#include<stdio.h>
int main()
{
int
a;
printf("输入你的成绩:");
scanf("%d",&a);
if(a>100||a<0)
{
printf("非法输入");
}
else
{
a=a/10;
switch(a)
{
case 10:
printf("A\n");break;
case 9: printf("A\n");break;
case 8: printf("B\n");break;
case 7: printf("C\n");break;
case 6: printf("D\n");break;
default:printf("E\n");break;
}
}
return
0;
}追问谢谢
追答第一次被采纳 好开心 *采
热心网友 时间:2023-10-31 19:47
#include <stdio.h>
int main()
{
printf("请输入分数:");
char szscore[2+1] = {0};
scanf("%s", &szscore);
printf("等级为:");
switch (*szscore) {
case '9' : printf("A\n"); break;
case '8' : printf("B\n"); break;
case '7' : printf("C\n"); break;
case '6' : printf("D\n"); break;
default : printf("E\n");
}
return 0;
}
希望能帮助到你!