第1个回答 2013-11-12
#include<stdio.h>
main()
{
int x;
char y;
retry:
printf("请输入成绩:\n");
scanf("%d",&x);
if(x<0||x>100)
{printf("成绩输入错误\n");
goto retry;
}
switch(x/5)
{
case 12: y='D';break;
case 13:
case 14: y='C';break;
case 15:
case 16:
case 17: y='B';break;
case 18:
case 19:
case 20: y='A';break;
default :y='E';break;
}
printf("%d分的等级为%c.\n",x,y);
}
//成功运行本回答被提问者采纳
第2个回答 2013-11-12
#include <stdio.h>
int main () {
int n;
char c;
scanf("%d",&n);
switch (n / 10) {
case 10: c = 'A'; break;
case 9: c = 'A'; break;
case 8: c = 'B'; break;
case 7: if (n > 74) c = 'B'; else c = 'C'; break;
case 6: if (n > 64) c = 'C'; else c = 'D'; break;
default: c = 'E'; break;
}
printf("%c\n",c);
return 0;
}