Tower of honoi in c program
Tower of honoi in c program:
#include stdio.h
void toh(int n,int source,int aux,int dest){
if(n==1){
printf("Move the disk from tower no: %d to tower no: %d\n",source,dest);
return;
}
toh(n-1,source, dest,aux);
toh(1,source,aux,dest);
toh(n-1,aux, source,dest);
}
int main()
{
toh(5,1,2,3);
return 0;
}
#include stdio.h
void toh(int n,int source,int aux,int dest){
if(n==1){
printf("Move the disk from tower no: %d to tower no: %d\n",source,dest);
return;
}
toh(n-1,source, dest,aux);
toh(1,source,aux,dest);
toh(n-1,aux, source,dest);
}
int main()
{
toh(5,1,2,3);
return 0;
}
Comments
Post a Comment