不是VIP会员,不能显示答案

题目解答

题目:
#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;
}




判断题

1) 当输入为“2 3”时,customFunction(2,3)的返回值为“64”。( )

A.正确
B.错误
2) 当b为负数时,customFunction(a,b)会陷入无限递归。( )

A.正确
B.错误
3) 当b的值越大,程序的运行时间越长。( )
A.正确
B.错误


选择题

4) 当输入为“5 4”时,customFunction(5,4)的返回值为( )。

A.5
B.25
C.250
D.625
5) 如果输入x = 3和y = 3,则程序的最终输出为()

A.“27”
B.“81”
C.“144”
D.“256”
6) (4分)若将customFunction函数改为“return a + customFunction(a-1,b-1)”;并输入“3 3”,则程序的最终输出为()。
A.9
B.16
C.25
D.36
考点:
分析:
解答:
评论:
老师: