2 条题解

  • 1
    @ 2026-7-25 11:41:08

    这题样例历好水我交了个标准汉诺塔程序AC了

    • 1
      @ 2026-7-24 19:25:28
      
      #include <iostream>
      using namespace std;
      int n;
      void hnt(int n,char a,char b,char c) {
          if(n==0) return;
          hnt(n-1,a,c,b);
          cout<<n<<' '<<a<<' '<<b<<'\n';
          hnt(n-1,c,b,a);
      }
      
      int main() {
          ios::sync_with_stdio(false);
          cin.tie(nullptr);
          cin >> n;
          hnt(n,'A','B','C');
          return 0;
      }
      • 1

      信息

      ID
      168
      时间
      1000ms
      内存
      256MiB
      难度
      5
      标签
      递交数
      7
      已通过
      4
      上传者