#76. 递推与递归第十题(NOIP2014)

递推与递归第十题(NOIP2014)

第十题(NOIP2014)

#include<iostream>
using namespace std;
int fun(int n, int minNum, int maxNum) {
    int tot, i;
    if (n == 0) return 1;
    tot = 0;
    for (i = minNum; i <= maxNum; i++)
        tot += fun(n -  1, i + 1, maxNum);
    return tot;
}
int main() {
    int n;
    cin >> n;
    cout << fun(n, 1, 6) << endl;
    return 0;
}
  1. 【判断题】将第5行删掉,程序编译错误。
    {{ select(1) }}
  • 正确
  • 错误
  1. 【判断题】当输入的n的绝对值在1000以内时,程序不一定能正常运行。
    {{ select(2) }}
  • 正确
  • 错误
  1. 【判断题】将第4行的内容接在第2行后,程序输出与原样不同。
    {{ select(3) }}
  • 正确
  • 错误
  1. 【判断题】将第4行的内容去掉,程序将会运行错误。
    {{ select(4) }}
  • 正确
  • 错误
  1. 【选择题】fun(2, 1, 6)的值为( )。
    {{ select(5) }}
  • 15
  • 10
  • 6
  • 3
  1. 【选择题】fun(3, 1, 6)的值为( )。
    {{ select(6) }}
  • 20
  • 10
  • 4
  • 1