MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / tower_of_hanoi

Function tower_of_hanoi

CPP/questions/towerofhanoi.cpp:4–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2using namespace std;
3
4void tower_of_hanoi(int n, char from_rod, char aux_rod, char to_rod)
5{
6
7
8 if (n == 1)
9 cout << "Move a rod from the top of " << from_rod << " to the top of " << to_rod << '\n';
10 else
11 {
12 tower_of_hanoi(n - 1, from_rod, to_rod, aux_rod);
13 tower_of_hanoi(1, from_rod, aux_rod, to_rod);
14 tower_of_hanoi(n - 1, aux_rod, from_rod, to_rod);
15 }
16}
17
18int main()
19{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected