#include<iostream>using namespace std;
void hanoi(char A,char B,char C,int n){ if(n == 1) { cout<<A<<"-->"<<C<<endl; } else { hanoi(A,C,B,n-1); cout<<A<<"-->"<<C<<endl; hanoi(B,A,C,n-1); }}void main(){ int n; cout<<"input n:>"; cin>>n; hanoi('A','B','C',n);}
新闻热点
疑难解答