1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #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 0; } |
0 of 6 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 6 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1、当输入为 2 3
时,customFunction(2, 3)
的返回值为 64。( )
当 b 为负数时,customFunction(a, b)
会陷入无限递归。( )
4、当 b的值越大,程序的运行时间越长。( )
4、当输入为 5 4
时,customFunction(5, 4)
的返回值为( )。
5、如果输入 x=3
和 y=3
,则程序的最终输出为( )
6、若将 customFunction
函数改为 return a + customFunction(a-1, b-1);
,并输入 3 3
,则程序的最终输出为( )。