1. 判断

    1. false
    2. true
    3. false
  2. 表达式

    1. number >= 90 && number < 100
    2. char != ‘q’ && char != ‘k’
    3. number >= 1 && number <= 9 && number != 5
    4. !(number >= 1 && number<= 9)
  3. 简化

    没读懂源代码,看答案吧

  4. 表达式的值(这里的 true 和 false 是 1 和 0 的意思)

    1. true
    2. false
    3. true
    4. 6
    5. 10
    6. false
  5. 打印

    #%#%¥#%#%#%&#%#%#%¥#%#%#%

  6. 打印

    1
    2
    3
    
    fat hat cat Oh no!
    hat cat Oh no!
    cat Oh no!
    
  7. 错误

    1. 没有给用户输入提示
    2. 第一个 if 改成 'a' <= ch && 'z' >= ch
    3. else if 处 || 改成 `&&,后面补个括号
    4. oc++ 上面加一个 else
    5. printif 引号
    6. 注释不完全
  8. 打印

    You are 40. Here is a raise.

    You are 60. Here is a raise.

    You are 65. Here is your gold watch.

    只打印You are 65. Here is your gole watch. 而且会不断重复,因为 if 使用了 = 导致赋值了

  9. 打印

    1
    2
    3
    4
    5
    6
    7
    8
    
    Step 1
    Step 2
    Step 3
    Step 1
    Step 1
    Step 3
    Step 1
    Done
    
  10. 重写

    思路:

    获取一个输入,当输入为 # 时结束循环。当输入为 \n 时直接获取下一个输入

    执行 Step 1

    当输入为 ‘c’,直接下一个循环

    当输入为 ‘b’,结束循环

    当输入为 ‘h’,执行 Step 3

    均不是时,执行 Step 2, Step 3

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    
    #include<stdio.h>
    int main(void)
    {
        char ch;
    
        while ((ch = getchar()) != '#')
        {
            switch(ch)
            {
                case '\n': break;
                case 'c':
                case 'b':
                    printf("Step 1\n");
                    break;
                case 'h':
                    printf("Step 1\nStep 3\n");
                    break;
                default:
                    printf("Step 1\nStep 2\nStep 3\n");
                    break;
            }
            if (ch = 'b')
                break;
        }
    }
    

    答案中的思路

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    #include<stdio.h>
    int main(void)
    {
        char ch;
    
        while ((ch = getchar()) != '#')
        {
            if ( ch != '\n');
            {
                printf("Step1\n");
                if (ch = 'b')
                    break;
                else if (ch != 'c')
                {
                    if (ch != 'h')
                        printf("Step 2\n");
                    printf("Step 3\n");
                }
            }
        }
        printf("Done\n");
    }