酷代码 AI
菜单
服务商

jiangshangtiyongC

```pascal program HanoiTower; var N: integer; moves: longint; procedure hanoi(n: integer; source, target, auxiliary: char); begin if n = 1 then begin writeln(source, '->1->', target); moves := moves + 1; end else begin hanoi(n - 1, source, auxiliary, target); writeln(source, '->', n, '->', target); moves := moves + 1; hanoi(n - 1, auxiliary, target, source); end; end; begin readln(N); moves := 0; hanoi(N, 'a', 'c', 'b'); writeln(moves); end. ``` [2026-01-05 17:51:57 | AI问答 | 171点数解答]

发财导航,免费问AI
实用工具查看更多