#include<stdio.h>
intmain()
{
floatscore;
chargrade;
printf("請輸入學生成績:");
scanf_s("%f",&score);
while(score>100||score<0)
printf("\n輸入有誤,請重新輸入!");
}
switch((int)(score/10))
case10:
case9:grade="A";break;
case8:grade="B";break;
case7:grade="C";break;
case6:grade="D";break;
case5:
case4:
case3:
case2:
case1:
case0:grade="E";
printf("學生成績是%5.1f:,等級是:%C。\n",score,grade);
#include<stdio.h>
intmain()
{
floatscore;
chargrade;
printf("請輸入學生成績:");
scanf_s("%f",&score);
while(score>100||score<0)
{
printf("\n輸入有誤,請重新輸入!");
scanf_s("%f",&score);
}
switch((int)(score/10))
{
case10:
case9:grade="A";break;
case8:grade="B";break;
case7:grade="C";break;
case6:grade="D";break;
case5:
case4:
case3:
case2:
case1:
case0:grade="E";
}
printf("學生成績是%5.1f:,等級是:%C。\n",score,grade);
}