#1291. [CSP2024 入门级] 第 32 题

[CSP2024 入门级] 第 32 题

#include <iostream>
#include <cmath>
using namespace std;

int customFunction(int a, int b) {
    if (b == 0) return a;
    return a + customFunction(a, b-1);
}

int main() {
    int x, y;
    cin >> x >> y;
    int result = customFunction(x, y);
    cout << pow(result, 2) << endl;
}

将递归语句改为 return a + customFunction(a-1,b-1);

输入 3 3 时,程序最终输出为( )。

{{ select(1) }}

  • 99
  • 1616
  • 2525
  • 3636