سلام به شما دوست گرامی ، اینم کد شما بزبان سی پلاس پلاس :
#include <iostream>
#include <conio>
#include <iomanip>
void hanoi(int d,char first,char help,char second){
if(d==1){
cout<<"Disk"<<" "<<d<<setw(6)<<first<<"===>"<<second<<endl;}
else{
hanoi(d-1,first,second,help);
cout<<"Disk"<<" "<<d<<setw(6)<<first<<"===>"<<second<<endl;
hanoi(d-1,help,first,second);
}
}
int main()
{
int disks;
cout<<"We Want to Move Disks From Tower A to C\n";
cout<<"How many disks do you want to move?\n";
cin>>disks;
cout<<"============================\n";
hanoi(disks,'A','B','C');
cout<<endl;
getch();
}
موفق باشید !!!