将成绩转换为等级(switch)

输入格式
Enter n:
输出等级(ABCDE)

#include
int main(void)
{
     int grade;
double n;
printf("Enter n:");
scanf("%lf",&n);
if(n<0||n>100)
printf("It is wrong!");
switch(grade=n/10){
     
case 10:
case 9:printf("A");break;
case 8:printf("B");break;
case 7:printf("C");break;
case 6:printf("D");break;
default:printf("E");break;}
return 0;
 } 

你可能感兴趣的:(c语言)