https://ide.codingblocks.com/#/s/30952
https://hack.codingblocks.com/contests/c/457/358
I used recursion. what’s wrong?
Tower of hanoi in hb
1 Like
#include
using namespace std;
void move(int n,char src,char helper,char dest)
{
if(n==0)
{
return;
}
move(n-1 ,src,helper,dest);
cout<<“Moving ring” <<" “<< n <<” “<< “From” <<” “<< src <<” “<< “to” <<” "<< dest << “\n”;
move(n-1,helper,dest,src);
}
int main() {
int n;
cin>>n;
move(n,‘A’,‘B’,‘C’);
return 0;
}
why i am getting wrong output