Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
44570 wutong 汉诺塔的移动过程 C++ Accepted 28 MS 256 KB 325 2024-03-31 12:36:13

Tests(3/3):


#include <bits/stdc++.h> using namespace std; int s = 0; void move(int n,char a,char b,char c) { if(n == 1) { s += 1; cout<<a<<"->"<<c<<endl; } else { move(n-1,a,c,b); move(1,a,b,c); move(n-1,b,a,c); } return; } int main() { int n; cin >> n; move(n,'A','B','C'); cout << s; return 0; }


Judgement Protocol: