Tweet
/* Program for solution of Tower of Hanoi */
#include<stdio.h>
main()
{
char source= 'S',temp= 'T ', dest= 'D';
int ndisk;
printf("Enter the number of disks : ");
scanf ( "%d", &ndisk );
printf ("Sequence is :\n");
toh( ndisk, source, temp, dest );
}
toh( int ndisk, char source, char temp, char dest )
{
if ( ndisk > 0 )
{
toh ( ndisk-1, source, dest, temp );
printf ( "Move Disk %d %c-->%c\n", ndisk, source,dest );
toh( ndisk-1, temp, source, dest );
}
}/*End of toh()*/
Tower of Hanoi programming in C
Posted by
LAHAUL SETH
~
Tower of Hanoi programming in C
2011-11-30T10:35:00+05:30
LAHAUL SETH
Programming in C
|
Comments
Tower of Hanoi programming in C
2011-11-30T10:35:00+05:30
LAHAUL SETH
Programming in C
|