| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 88360 | sh25_wuyy | 汉诺塔的移动过程 | C++ | 通过 | 27 MS | 248 KB | 445 | 2026-05-10 19:10:51 |
#include <iostream> using namespace std; int hanoi(int n,char from,char to,char aux){ if(n==1){ cout<<from<<"->"<<to<<endl; return 1; }int count=0; count+=hanoi(n-1,from,aux,to); cout<<from<<"->"<<to<<endl; count++; count+=hanoi(n-1,aux,to,from); return count; }int main(){ int n; cin>>n; int total_moves=hanoi(n,'A','C','B'); cout<<total_moves<<endl; return 0; }