?? hanoirecursive.cpp
字號:
// Recursive Towers of Hanoi
#include <iostream>
using namespace std;
void towersOfHanoi(int n, int x, int y, int z)
{// Move the top n disks from tower x to tower y.
// Use tower z for intermediate storage.
if (n > 0)
{
towersOfHanoi(n-1, x, z, y);
cout << "Move top disk from tower " << x
<< " to top of tower " << y << endl;
towersOfHanoi(n-1, z, y, x);
}
}
void main(void)
{
cout << "Moves for a three disk problem are" << endl;
towersOfHanoi(3,1,2,3);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -