https://www.acmicpc.net/problem/9498
시험 점수를 입력받아 90 ~ 100점은 A, 80 ~ 89점은 B, 70 ~ 79점은 C, 60 ~ 69점은 D, 나머지 점수는 F를 출력하는 프로그램을 작성하시오.
<script>
#include <stdio.h>
int main()
{
int score;
scanf("%d", &score);
if (score >= 90) {
printf("A");
}
else if (score >= 80) {
printf("B");
}
else if (score >= 70) {
printf("C");
}
else if (score >= 60) {
printf("D");
}
else {
printf("F");
}
return 0;
}
</script>
❗ 순서를 반대로 60>= 70>= 80>= 90>= 로 설정하면, A
가 출력되어야 할 99가 들어가도 60>= 첫 조건을 만족하고 D
가 나와버린다.