Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ <h1>
</li>


<!-- <li>
Add your name here
</li> -->
<li>
Prashant singh kannoji
</li>

</ul>
</body>
Expand Down
20 changes: 20 additions & 0 deletions towerofhanoi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;
void towerOfHanoi(int n, char source, char destination, char auxiliary) {
if (n == 1) {
cout << "Move disk 1 from " << source << " to " << destination << endl;
return;
}
towerOfHanoi(n - 1, source, auxiliary, destination);
cout << "Move disk " << n << " from " << source << " to " << destination << endl;
towerOfHanoi(n - 1, auxiliary, destination, source);
}

int main() {
int numDisks;
cout << "Enter the number of disks: ";
cin >> numDisks;
towerOfHanoi(numDisks, 'A', 'C', 'B');

return 0;
}