提交时间:2023-10-05 09:08:38
运行 ID: 105046
#include<bits/stdc++.h> #define int long long using namespace std; int k=0,n; void Hanoi(int n,char a,char c,char b){ if(n==0){ return; } Hanoi(n-1,a,b,c); k++; cout<<a<<"->"<<c<<endl; Hanoi(n-1,b,c,a); } signed main(){ int n; cin>>n; Hanoi(n,'A','C','B'); return 0; }