1. 程式人生 > >經典漢諾塔

經典漢諾塔

mes oid class using sin AI color urn void

#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; }

經典漢諾塔