杭电ACM大牛们帮我看看2004题这个代码为啥WA..
#include<stdio.h>intmain(){intgrade,score;while(scanf("%d",&score)!=EOF){grade=score/...
#include<stdio.h>
int main()
{
int grade,score;
while(scanf("%d",&score)!=EOF)
{
grade=score/10;
switch(grade)
{
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");
}
}
return 0;
} 展开
int main()
{
int grade,score;
while(scanf("%d",&score)!=EOF)
{
grade=score/10;
switch(grade)
{
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");
}
}
return 0;
} 展开
2个回答
展开全部
#include<stdio.h>
int main()
{
int grade,score;
while(scanf("%d",&score)!=EOF)
{
grade=score/10;
if(score>100||score<0) // 添加判定
printf("Score is error!\n");
else
switch(grade)
{
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");
}
}
return 0;
}
int main()
{
int grade,score;
while(scanf("%d",&score)!=EOF)
{
grade=score/10;
if(score>100||score<0) // 添加判定
printf("Score is error!\n");
else
switch(grade)
{
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");
}
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询