解题报告:

虽说简单,但对新手应该还是有一点难度,试着理解吧,这就是“递归”和“分治”qwq

#include<iostream>
using namespace std;
int n;
void f(int x,int from,int to,int top)
{
    if(x==top)
    {
        cout<<from<<" --> "<<to<<endl;
        return ;
    }
    int nowto;
    for(int i=1;i<=3;i++)
    {
        if(i!=from&&i!=to)//ºÏÊʵÄÂä½Åµã 
        {
            nowto=i;
            break;
        }
    }
    f(x+1,from,nowto,top);
    cout<<from<<" --> "<<to<<endl;
    f(x+1,nowto,to,top);
}
int main()
{
    cout<<"Enter the starting number of disks: ";
    cin>>n;
    f(1,1,3,n);
}

魔理沙很可爱对不对qwq