Tweet
/* Tower of Hanoi using recursion */
#include<iostream.h>
#include<conio.h>
void move(int n,int A,int C,int B)
{
if(n==1)
cout<<"\t Move the upper disc from Stack-" <<A<< " to Stack-"
<<C<< "\n";
else
{
move(n-1,A,B,C);
move(1,A,C,B);
move(n-1,B,C,A);
}
}
main( )
{
clrscr( );
cout<<"\n\t ****TOWERS OF HANOI****\n"<<endl;
cout<<" The Mystery of Towers of Hanoi is as follows : \n"<<endl;
move(4,1,3,2);
cout<<"\n\t *************************************************\n"<<endl;
getch( );
return 0;
}
Tower of Hanoi using recursion in C
Posted by
LAHAUL SETH
~
Tower of Hanoi using recursion in C
2012-05-05T13:44:00+05:30
LAHAUL SETH
C++
|
Comments
Tower of Hanoi using recursion in C
2012-05-05T13:44:00+05:30
LAHAUL SETH
C++
|