#include<stdio.h>int main(){float x;int leap;scanf("%f",&x);if(x>=90){if(x>=80&&x<90){if(x>=70&&x<80){if(x>=60&&x<70){if(x<60)leap=1;}else leap=2;}else leap=3;}else leap=4;}else leap=5;switch(leap){case 1:printf("you grade is:E");break;case 2:printf("you grade is:D");break;case 3:printf("you grade is:C");break;case 4:printf("you grade is:B");break;case 5:printf("you grade is:A");break;}return 0;}
2 回答
倚天杖
TA贡献1828条经验 获得超3个赞
前面if嵌套不对。修改如下
#include<stdio.h>
int main()
{
float x;
int leap;
scanf("%f",&x);
if(x<90)
{
if(x<80)
{
if(x<70)
{
if(x<60)
{
leap=1;
}else leap=2;
}else leap=3;
}else leap=4;
}else leap=5;
switch(leap)
{case 1:printf("you grade is:E");break;
case 2:printf("you grade is:D");break;
case 3:printf("you grade is:C");break;
case 4:printf("you grade is:B");break;
case 5:printf("you grade is:A");break;
}
return 0;
}
qq_遁去的一_1
TA贡献1725条经验 获得超7个赞
if(x>=90)
{
if(x>=80&&x<90)
{
if(x>=70&&x<80)
{
if(x>=60&&x<70)
{
if(x<60)
leap=1;
}else leap=2;
}else leap=3;
}else leap=4;
}else leap=5;
这里有逻辑错误!
添加回答
举报
0/150
提交
取消