6. 编写程序:根据从键盘输入的学生成绩给出相应的等级。

2024-11-24 12:40:23
推荐回答(1个)
回答1:

#include "stdio.h"
char swi(int grade)
{ int s;
s=grade/10;
switch(s)
{ case 10:return 'A';
case 9: return 'A';
case 8:return 'A';break;
case 7:return 'B';break;
case 6: return 'C';break;
case 5:return 'D';
case 4:return 'D';
case 3:return 'D';
case 2:return 'D';
case 1:return 'D';break;
default :printf("wrong"); }
}
main()
{ int grade;
char ch;
printf("enter a grade\n");
scanf("%d",&grade);
ch=swi(grade);
printf("%c",ch);

}