#1025. 递归阅读选择题

递归阅读选择题

  1. 阅读代码,写出其结果
void hello(int n) {
    if (n == 1) cout << n << " ";
    else {
        cout << n << " ";
        hello(n - 1);
    }
}

hello(10); 的结果是 {{ input(1) }}


  1. 阅读代码,写出其结果
void hello(int n) {
    if (n == 1) cout << n << " ";
    else {
        hello(n - 1);
        cout << n << " ";
    }
}

hello(10); 的结果是 {{ input(2) }}


  1. 阅读代码,写出其结果
void hello(int n) {
    if (n == 1) cout << n << " ";
    else {
        hello(n - 1);
        cout << n << " ";
        hello(n - 1);
    }
}

hello(4); 的结果是 {{ input(3) }}