| 分數區間 | 等級 |
|---|---|
| 90 ~ 100 | A |
| 80 ~ 89 | B |
| 70 ~ 79 | C |
| 60 ~ 69 | D |
| 0 ~ 59 | E |
輸入超出 [0,100] 輸出 Score is error!。
if (score < 0 || score > 100)#include <stdio.h>
int main() {
int score;
while (scanf("%d", &score) != EOF) {
if (score < 0 || score > 100) {
printf("Score is error!\n");
} else if (score >= 90) {
printf("A\n");
} else if (score >= 80) {
printf("B\n");
} else if (score >= 70) {
printf("C\n");
} else if (score >= 60) {
printf("D\n");
} else {
printf("E\n");
}
}
return 0;
}
else if 互斥90~100 含兩端,score >= 90 正確覆蓋