Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void move(char from, char to)
- {
- cout << "Move from " << from << " to " << to << endl;
- }
- void hanoi(char from, char to, char mid, int cnt)
- {
- if (cnt == 1) {
- move(from, to);
- } else {
- hanoi(from, mid, to, cnt - 1);
- move(from, to);
- hanoi(mid, to, from, cnt - 1);
- }
- }
- int main()
- {
- hanoi('A', 'C', 'B', 3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement