c语言求解error C2059: syntax error : ✀type✀

2024-12-23 11:22:06
推荐回答(2个)
回答1:

错误的地方不是那里

#include
void main ( )
{
float score;
char grade;
printf("请输入成绩%%f\n");
scanf("%f",&score);
switch(int(score/10))
{
case 10:
case 9: grade='A';break;//是'A'有单引号
case 8: grade='B';break;
case 7: grade='C';break;
case 6: grade='D';break;
default: grade='E';break;

}
printf("grade=%c\n",grade);
}

回答2:

#include
#include

void main ( )
{
float score;
char grade;
printf("请输入成绩%%f\n");
scanf("%f",&score);
switch(int(score/10))
{
case 10:
case 9:
grade = 'A';
break;
case 8:
grade = 'B';
break;
case 7:
grade = 'C';
break;
case 6:
grade = 'D';
break;
default:
grade = 'E';
break;
}
printf("grade=%c\n",grade);
system("pause");
}