From 72af0dedf9e18911da65b9a5c4906689e868d9fc Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Mon, 8 Jun 2026 17:10:31 +0800 Subject: [legacy] Add functional and performance test suites --- rcc-legacy/tests/sysy_lvX/088_hanoi.sy | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 rcc-legacy/tests/sysy_lvX/088_hanoi.sy (limited to 'rcc-legacy/tests/sysy_lvX/088_hanoi.sy') diff --git a/rcc-legacy/tests/sysy_lvX/088_hanoi.sy b/rcc-legacy/tests/sysy_lvX/088_hanoi.sy new file mode 100644 index 0000000..063bef8 --- /dev/null +++ b/rcc-legacy/tests/sysy_lvX/088_hanoi.sy @@ -0,0 +1,27 @@ + +void move(int x, int y) +{ + putint(x); putch(32); putint(y); putch(44); putch(32); +} + +void hanoi(int n, int one, int two, int three) +{ + if (n == 1) + move(one, three); + else { + hanoi(n - 1, one, three, two); + move(one, three); + hanoi(n - 1, two, one, three); + } +} + +int main() +{ + int n = getint(); + while (n > 0) { + hanoi(getint(), 1, 2, 3); + putch(10); + n = n - 1; + } + return 0; +} -- cgit v1.2.3