求 用C语言中switch语句编写学生成绩问题
#include
void main()
{
double score;
printf("请输入分数:\n");
scanf("%lf",&score);
switch((int)(score/10))//switch((int)score/10)出现严重错误,switch(((int)score)/10)出现严重错误,
{
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("Error!\n");
}
}
例二:
#include
void main()
{
char rank;
printf("请输入分数等级:(A、B、C、D、E)\n");
scanf("%c",&rank);
switch(rank)//switch((int)sc