#include<iostream>
using namespace std;
int tower(int, char,char , char);
int main()
{
int num;
cout<<"ENTER NO OF DISK"<<endl;
cin>>num;
tower(num,'A','B','c');
}
int tower(int num, char beg, char aux, char End)
{
if(num>0)
{
tower(num-1,beg,End,aux);
cout<<beg<<" -> "<<End<<endl;
tower(num-1,aux,beg,End);
}
return 0;
}
using namespace std;
int tower(int, char,char , char);
int main()
{
int num;
cout<<"ENTER NO OF DISK"<<endl;
cin>>num;
tower(num,'A','B','c');
}
int tower(int num, char beg, char aux, char End)
{
if(num>0)
{
tower(num-1,beg,End,aux);
cout<<beg<<" -> "<<End<<endl;
tower(num-1,aux,beg,End);
}
return 0;
}
No comments:
Post a Comment