使用switch编写根据考试分数打印等级
时间: 2023-05-22 12:01:47 浏览: 72
好的,以下是使用 switch 编写根据考试分数打印等级的代码:
```
#include <stdio.h>
int main() {
int score;
printf("请输入考试分数:");
scanf("%d", &score);
switch (score / 10) {
case 10:
case 9:
printf("优秀\n");
break;
case 8:
printf("良好\n");
break;
case 7:
printf("中等\n");
break;
case 6:
printf("及格\n");
break;
default:
printf("不及格\n");
break;
}
return 0;
}
```
希望能对你有所帮助!