From 7ad7b90b924421014a77bb3fcf3385885b35e4c4 Mon Sep 17 00:00:00 2001 From: ooreally Date: Fri, 11 Oct 2019 13:03:09 +0530 Subject: [PATCH 1/3] added algo for tower-of-hanoi in cpp --- CPP/Algorithm/tower_of_hanoi.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 CPP/Algorithm/tower_of_hanoi.cpp diff --git a/CPP/Algorithm/tower_of_hanoi.cpp b/CPP/Algorithm/tower_of_hanoi.cpp new file mode 100644 index 0000000..467e534 --- /dev/null +++ b/CPP/Algorithm/tower_of_hanoi.cpp @@ -0,0 +1,28 @@ +// C++ recursive function to +// solve tower of hanoi puzzle +#include +using namespace std; + +void towerOfHanoi(int n, char from_rod, + char to_rod, char aux_rod) +{ + if (n == 1) + { + cout << "Move disk 1 from rod " << from_rod << + " to rod " << to_rod< Date: Fri, 11 Oct 2019 13:07:33 +0530 Subject: [PATCH 2/3] updated readme.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 35e3a47..e9396ba 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@
  • KMP Algorithm
  • Boyre Moore Voting Algorithm
  • Sepa Algorithm to generate all Permutation
  • +
  • Algorithm for tower of Hanoi
  • ## Want to Contribute? From b7a425b16e43e447bf659236d7399be3e9ddace8 Mon Sep 17 00:00:00 2001 From: ooreally Date: Sat, 12 Oct 2019 04:25:44 +0530 Subject: [PATCH 3/3] added tower of hanoi algo --- CPP/Algorithm/tower_of_hanoi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CPP/Algorithm/tower_of_hanoi.cpp b/CPP/Algorithm/tower_of_hanoi.cpp index 467e534..7263c02 100644 --- a/CPP/Algorithm/tower_of_hanoi.cpp +++ b/CPP/Algorithm/tower_of_hanoi.cpp @@ -1,7 +1,7 @@ // C++ recursive function to // solve tower of hanoi puzzle #include -using namespace std; +using namespace std; void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod)