|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
输入一个百分制的成绩t,将其转换成对应的等级,具体转换规则如下:
90~100为A;
80~89为B;
70~79为C;
60~69为D;
0~59为E;
下面网上答案的代码
#include<stdio.h>
int main ()
{
int t;
while (scanf("%d",&t)!=EOF)
{
if(90<=t&&t<=100)printf("%c\n",'A');
else if(80<=t&&t<=89)printf("%c\n",'B');
else if(70<=t&&t<=79)printf("%c\n",'C');
else if(60<=t&&t<=69)printf("%c\n",'D');
else if(0<=t&&t<=59)printf("%c\n",'E');
else printf("Score is error!\n");
}
return 0;
}
然后接下来是我的代码
#include<stdio.h>
int main()
{ int t,s;
while(scanf("%d",&t)!=EOF)
{ s=t/10;
switch(s)
{ case 10:
case 9: printf("A\n"); break;
case 8: printf("B\n");break;
case 7: printf("C\n");break;
case 6: printf("D\n");break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
printf("E\n");break;
default:printf("Score is error!\n"); break;
}
}
return 0;
}
同样题目,运行结果也没问题,为什么我这个提交之后就是WA(Wrong Answer)呢?
|
|