经典汉诺塔

#include"iostream"
using namespace std;

void move(int n,char a,char b,char c){
    if(n == 1){
        cout<<n<<ends<<a<<" to "<<c<<endl;
    }
    else{
        move(n - 1,a,c,b);
        cout<<n<<ends<<a<<" to "<<c<<endl;
        move(n - 1,b,a,c);
    }
}

int main(){
    move(3,'A','B','C');
    return 0;
}
原文地址:https://www.cnblogs.com/oleolema/p/9028403.html