# if else 和 switch 使用

<p>输入学生成绩&#xff0c;
若成绩在95分以上&#xff0c;输出“A”&#xff1b;<br />
若成绩在85~94分&#xff0c;输出“B”&#xff1b;<br />
若成绩在75~84分&#xff0c;输出“C”&#xff1b;<br />
若成绩在65~74分&#xff0c;输出“D”&#xff1b;<br />
若成绩在65分以下&#xff0c;输出“E”。&#xff08;分别用if else 和 switch 语句完成&#xff09;</p>

## template

```cpp
#include "stdio.h"
int main()
{
    int score;
    scanf("%d", &score);
    if (score >= 95)
    {
        printf("A\n");
    }
    else if (score >= 85 && score <= 94)
    {
        printf("B\n");
    }
    else if (score >= 75 && score <= 84)
    {
        printf("C\n");
    }
    else if (score >= 65 && score <= 74)
    {
        printf("D\n");
    }
    else
    {
        printf("E\n");
    }
    printf("以下用switch语句实现相同功能\n");
    score = score - 5;
    score = score / 10;
    switch (score)
    {
    case 9:
        printf("A\n");
        break;
    case 8:
        printf("B");
        break;
    case 7:
        printf("C\n");
        break;
    case 6:
        printf("D\n");
        break;
    default:
        printf("E\n");
        break;
    }
}
```

## 答案

```cpp

```

## 选项

### A

```cpp

```

### B

```cpp

```

### C

```cpp

```