csppass
连续 00 XP登录 / 注册
202427判断题函数与递归普及/提高

程序(三):customFunction(2,3) 的返回值是否为64

题目

阅读下面的程序,回答问题。 #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; } 判断题:当输入为“2 3”时,customFunction(2,3)的返回值为“64”。( 填 √ 或 × )

考点拆解
递归函数
易错提醒
阅读程序题要按变量变化顺序手推,不要跳步
选择题要检查单位、边界和题目中的否定词