#include<stdio.h> #include<conio.h> int tower(int,char,char,char); main() { char source,temp,dest; int num; printf("ENTER THE NUMBER OF DISK FOR 'TOWER OF HANOI'\n"); scanf("%d",&num); tower(num,'A','B','C'); } int tower(int num,char source,char temp,char dest) { if(num==1) { printf("move %d from %c to %c\n\n",num,source,dest); } else { tower(num-1,source,dest,temp); printf("move %d from %c to %c\n\n",num,source,dest); tower(num-1,temp,source,dest); } }
New Android apps UniqueKey
Friday, 20 February 2015
Tower Of Hanoi
Labels:
C language
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment