填空题
例3-10(书上)//3_10.cpp#include using namespace std;//把src针的最上面一个盘子移动到dest针上void move(char src, char dest) { cout << src << " --> " << dest << endl;}//把n个盘子从src针移动到dest针,以medium针作为中介void hanoi(int n, char src, char medium, char dest) { if (n == 1)move(src, dest); else {hanoi(n - 1, src, dest, medium);move(src, dest);hanoi(n - 1, medium, src, dest); }}int main() { int m; cout << "Enter the number of diskes: "; cin >> m; cout << "the steps to moving " << m << " diskes:" << endl; hanoi(m,'A','B','C'); return 0;}试问:(1)当盘子的个数 为5时,hanoi函数被调用了( )次?(2)当盘子的个数 为10时,hanoi函数被调用了( )次?
套餐购买该问题答案仅对会员开放,欢迎开通会员 ¥ 19.9
0.64/天
1个月(不限次)
¥ 19.9
1000次
(不限时)
¥ 29.9
0.32/天
3个月(不限次)
¥ 59.9
0.16/天
1年(不限次)
立即支付