#include <stdio.h>
main()
{
float score;
int grade;
printf("Please enter score: ");
scanf("%f",&score);
if(score<0||score>100)
printf("输入数据错\n");
else
{
grade=(int)score/10;
switch(grade);
{
case 10 :
case 9 :printf("%.2f是A等\n",score);break;
case 8 :printf("%.2f是B等\n",score);break;
case 7 :printf("%.2f是C等\n",score);break;
case 6 :printf("%.2f是D等\n",score);break;
case 5:
case 4:
case 3:;
case 2:
case 1:
case 0:printf("%.2d是E等",score);break;
}
}
}
eg2_3.c
H:\eg2_3\eg2_3.c(15) : error C2046: illegal case
H:\eg2_3\eg2_3.c(16) : error C2046: illegal case
H:\eg2_3\eg2_3.c(16) : error C2043: illegal break
H:\eg2_3\eg2_3.c(17) : error C2046: illegal case
H:\eg2_3\eg2_3.c(17) : error C2043: illegal break
H:\eg2_3\eg2_3.c(18) : error C2046: illegal case
H:\eg2_3\eg2_3.c(18) : error C2043: illegal break
H:\eg2_3\eg2_3.c(19) : error C2046: illegal case
H:\eg2_3\eg2_3.c(19) : error C2043: illegal break
H:\eg2_3\eg2_3.c(20) : error C2046: illegal case
H:\eg2_3\eg2_3.c(21) : error C2046: illegal case
H:\eg2_3\eg2_3.c(22) : error C2046: illegal case
H:\eg2_3\eg2_3.c(23) : error C2046: illegal case
H:\eg2_3\eg2_3.c(24) : error C2046: illegal case
H:\eg2_3\eg2_3.c(25) : error C2046: illegal case
H:\eg2_3\eg2_3.c(25) : error C2043: illegal break
执行 cl.exe 时出错.
eg2_3.obj - 1 error(s), 0 warning(s)
哪里错了,大神。。。。。。我只是一个初学者啊,,,,
main()
{
float score;
int grade;
printf("Please enter score: ");
scanf("%f",&score);
if(score<0||score>100)
printf("输入数据错\n");
else
{
grade=(int)score/10;
switch(grade);
{
case 10 :
case 9 :printf("%.2f是A等\n",score);break;
case 8 :printf("%.2f是B等\n",score);break;
case 7 :printf("%.2f是C等\n",score);break;
case 6 :printf("%.2f是D等\n",score);break;
case 5:
case 4:
case 3:;
case 2:
case 1:
case 0:printf("%.2d是E等",score);break;
}
}
}
eg2_3.c
H:\eg2_3\eg2_3.c(15) : error C2046: illegal case
H:\eg2_3\eg2_3.c(16) : error C2046: illegal case
H:\eg2_3\eg2_3.c(16) : error C2043: illegal break
H:\eg2_3\eg2_3.c(17) : error C2046: illegal case
H:\eg2_3\eg2_3.c(17) : error C2043: illegal break
H:\eg2_3\eg2_3.c(18) : error C2046: illegal case
H:\eg2_3\eg2_3.c(18) : error C2043: illegal break
H:\eg2_3\eg2_3.c(19) : error C2046: illegal case
H:\eg2_3\eg2_3.c(19) : error C2043: illegal break
H:\eg2_3\eg2_3.c(20) : error C2046: illegal case
H:\eg2_3\eg2_3.c(21) : error C2046: illegal case
H:\eg2_3\eg2_3.c(22) : error C2046: illegal case
H:\eg2_3\eg2_3.c(23) : error C2046: illegal case
H:\eg2_3\eg2_3.c(24) : error C2046: illegal case
H:\eg2_3\eg2_3.c(25) : error C2046: illegal case
H:\eg2_3\eg2_3.c(25) : error C2043: illegal break
执行 cl.exe 时出错.
eg2_3.obj - 1 error(s), 0 warning(s)
哪里错了,大神。。。。。。我只是一个初学者啊,,,,