English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

u can solve this only if u know the concept of tower of hanoi program.

2007-02-06 00:19:28 · 4 answers · asked by lively 2 in Computers & Internet Programming & Design

4 answers

well here is the code in "C".....I use GCC compiler.....so better u run this on that....I am not sure abt tht other compilers.....

**********************************************************************

#include

void transfer(int n,char from[],char to[],char temp[]);
main()
{
int n;
char L[]="Left";
char C[]="Center";
char R[]="Right";
printf("Welcome to TOWERS OF HANOI\n\n");
printf("How many discs? ");
scanf("%d",&n);
printf("\n");
transfer(n,L,R,C);
}

void transfer(int n,char from[],char to[],char temp[])
{
if(n>0)
{
transfer(n-1,from,temp,to);
printf("Move disc %d from %s to %s\n",n,from,to);
transfer(n-1,temp,to,from);
}
return;
}


**********************************************************************

2007-02-06 01:14:01 · answer #1 · answered by Anonymous · 0 0

Hi there!

I'm not actually sure with the concept but the flow of program would have decrement or increment. Imagine two triangle and of it is inverted. The flow would be, the inverted triangle = 10 - 1, it would decrement by 1. Thus the other triangle would increment by 1. Somehow the program will flow like that...

Ei, hope that would help anyways to start the program you should have first the logic or flow of the system.

2007-02-06 00:41:23 · answer #2 · answered by simply_mica 3 · 0 0

there's a legend some Vietnamese or Indian temple which incorporates a large room with 3 time-worn posts in it surrounded via sixty 4 golden disks. The monks of Brahma, appearing out the command of an historic prophecy, have been shifting those disks, in accordance with the guidelines of the puzzle, on account that that factor. this might take an prolonged time. I did a undertaking on it in seventh grade

2016-10-01 12:27:55 · answer #3 · answered by Anonymous · 0 0

Dear XYZ,

rather than giving you the complete code, I am providing a link to the algorithm for this famous mathematical model.

http://hanoitower.mkolar.org/algo.html

I hope that you will get a good idea from the algo and solve the problem easily.

2007-02-06 00:37:16 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers