#3408. [GESP202406 五级 C++] 第 15 题

[GESP202406 五级 C++] 第 15 题

给定如下函数(函数功能同上题,增加输出打印):

int fun(int n) {
    cout << n << " ";
    if (n == 1) return 1;
    if (n == 2) return 2;
    return fun(n - 2) - fun(n - 1);
}

则当 n=4n = 4 时,屏幕上输出序列为( )。

{{ select(1) }}

  • 4 3 2 1
  • 1 2 3 4
  • 4 2 3 1 2
  • 4 2 3 2 1