Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
333929 孙一铭 【C6-6】汉诺塔 C++ 解答错误 0 20 MS 248 KB 465 2025-07-17 09:23:15

Tests(0/10):


#include<bits/stdc++.h> using namespace std; int h(int n, char s, char d, char t) { int s1 = 0; if (n == 1) { cout << s << "->" << d << endl; return 1; } s1 += h(n-1, s, t, d); cout << s << "->" << d << endl; s1++; s1 += h(n-1, t, d, s); return s1; } int main() { int n; cin >> n; for(int i=1;i<=n;i++){ cout<<i<<":"; cout <<h(n, 'a', 'c', 'b'); } return 0; }


测评信息: