From bc465121494b6f6a05d6119f88ea8b773c4e7ea0 Mon Sep 17 00:00:00 2001 From: Mukheem Mohammed <49473863+Mukheem1603@users.noreply.github.com> Date: Tue, 5 Nov 2019 23:53:26 +0530 Subject: [PATCH 1/2] Create towers_of_hanoi.c --- ds/towers_of_hanoi.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ds/towers_of_hanoi.c diff --git a/ds/towers_of_hanoi.c b/ds/towers_of_hanoi.c new file mode 100644 index 0000000..171cf7c --- /dev/null +++ b/ds/towers_of_hanoi.c @@ -0,0 +1,24 @@ +#include +#include +#include +void TOH(int n,char s,char d,char i) +{ + if(n==1) + { + printf("Move %d from %c to %c\n",n,s,d); + } + else + { + TOH(n-1,s,i,d); + printf("Move %d from %c to %c\n",n,s,d); + TOH(n-1,i,d,s); + } +} +void main() +{ + int n; + printf("Enter the number of discs:\n"); + scanf("%d",&n); + TOH(n,'s','d','i'); + +} From dfeea564b2e1995c366c2004bc5d873a78c8b143 Mon Sep 17 00:00:00 2001 From: Mukheem Mohammed <49473863+Mukheem1603@users.noreply.github.com> Date: Tue, 5 Nov 2019 23:57:04 +0530 Subject: [PATCH 2/2] Rename ds/towers_of_hanoi.c to Towers of Hanoi/TOH.cpp --- ds/towers_of_hanoi.c => Towers of Hanoi/TOH.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ds/towers_of_hanoi.c => Towers of Hanoi/TOH.cpp (100%) diff --git a/ds/towers_of_hanoi.c b/Towers of Hanoi/TOH.cpp similarity index 100% rename from ds/towers_of_hanoi.c rename to Towers of Hanoi/TOH.cpp