From 54a7ca2b132b13781f31c8b6fc5020a4c9706c91 Mon Sep 17 00:00:00 2001 From: lc <18783417278@163.com> Date: Mon, 13 Apr 2026 17:11:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E9=83=A8=E5=88=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=B5=8B=E8=AF=95=E7=9A=84=E6=96=B0=E5=A2=9E=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_case/case_lab3_1/array_1d.out | 2 ++ test/test_case/case_lab3_1/array_1d.sy | 16 ++++++++++++++++ test/test_case/case_lab3_1/div_mod.out | 2 ++ test/test_case/case_lab3_1/div_mod.sy | 10 ++++++++++ test/test_case/case_lab3_1/float_calc.out | 2 ++ test/test_case/case_lab3_1/float_calc.sy | 9 +++++++++ test/test_case/case_lab3_1/if_else_nested.out | 2 ++ test/test_case/case_lab3_1/if_else_nested.sy | 19 +++++++++++++++++++ test/test_case/case_lab3_1/recursion.out | 2 ++ test/test_case/case_lab3_1/recursion.sy | 10 ++++++++++ 10 files changed, 74 insertions(+) create mode 100644 test/test_case/case_lab3_1/array_1d.out create mode 100644 test/test_case/case_lab3_1/array_1d.sy create mode 100644 test/test_case/case_lab3_1/div_mod.out create mode 100644 test/test_case/case_lab3_1/div_mod.sy create mode 100644 test/test_case/case_lab3_1/float_calc.out create mode 100644 test/test_case/case_lab3_1/float_calc.sy create mode 100644 test/test_case/case_lab3_1/if_else_nested.out create mode 100644 test/test_case/case_lab3_1/if_else_nested.sy create mode 100644 test/test_case/case_lab3_1/recursion.out create mode 100644 test/test_case/case_lab3_1/recursion.sy diff --git a/test/test_case/case_lab3_1/array_1d.out b/test/test_case/case_lab3_1/array_1d.out new file mode 100644 index 0000000..3674aab --- /dev/null +++ b/test/test_case/case_lab3_1/array_1d.out @@ -0,0 +1,2 @@ +0 1 4 9 16 +0 diff --git a/test/test_case/case_lab3_1/array_1d.sy b/test/test_case/case_lab3_1/array_1d.sy new file mode 100644 index 0000000..2850075 --- /dev/null +++ b/test/test_case/case_lab3_1/array_1d.sy @@ -0,0 +1,16 @@ +int a[5]; +int main() { + int i = 0; + while (i < 5) { + a[i] = i * i; + i = i + 1; + } + i = 0; + while (i < 5) { + putint(a[i]); + putch(32); + i = i + 1; + } + putch(10); + return 0; +} diff --git a/test/test_case/case_lab3_1/div_mod.out b/test/test_case/case_lab3_1/div_mod.out new file mode 100644 index 0000000..27da0f8 --- /dev/null +++ b/test/test_case/case_lab3_1/div_mod.out @@ -0,0 +1,2 @@ +13 7 30 3 1 +0 diff --git a/test/test_case/case_lab3_1/div_mod.sy b/test/test_case/case_lab3_1/div_mod.sy new file mode 100644 index 0000000..4f964e0 --- /dev/null +++ b/test/test_case/case_lab3_1/div_mod.sy @@ -0,0 +1,10 @@ +int main() { + int a = 10; + int b = 3; + putint(a + b); putch(32); + putint(a - b); putch(32); + putint(a * b); putch(32); + putint(a / b); putch(32); + putint(a % b); putch(10); + return 0; +} diff --git a/test/test_case/case_lab3_1/float_calc.out b/test/test_case/case_lab3_1/float_calc.out new file mode 100644 index 0000000..55d583a --- /dev/null +++ b/test/test_case/case_lab3_1/float_calc.out @@ -0,0 +1,2 @@ +0x1.cp+1 -0x1p-1 0x1.8p+1 0x1.8p-1 +0 diff --git a/test/test_case/case_lab3_1/float_calc.sy b/test/test_case/case_lab3_1/float_calc.sy new file mode 100644 index 0000000..98a61ab --- /dev/null +++ b/test/test_case/case_lab3_1/float_calc.sy @@ -0,0 +1,9 @@ +int main() { + float a = 1.5; + float b = 2.0; + putfloat(a + b); putch(32); + putfloat(a - b); putch(32); + putfloat(a * b); putch(32); + putfloat(a / b); putch(10); + return 0; +} diff --git a/test/test_case/case_lab3_1/if_else_nested.out b/test/test_case/case_lab3_1/if_else_nested.out new file mode 100644 index 0000000..043e571 --- /dev/null +++ b/test/test_case/case_lab3_1/if_else_nested.out @@ -0,0 +1,2 @@ +3 +0 diff --git a/test/test_case/case_lab3_1/if_else_nested.sy b/test/test_case/case_lab3_1/if_else_nested.sy new file mode 100644 index 0000000..dc7e23e --- /dev/null +++ b/test/test_case/case_lab3_1/if_else_nested.sy @@ -0,0 +1,19 @@ +int main() { + int a = 5; + int b = 10; + if (a > b) { + putint(1); + } else { + if (a == 5) { + if (b != 10) { + putint(2); + } else { + putint(3); + } + } else { + putint(4); + } + } + putch(10); + return 0; +} diff --git a/test/test_case/case_lab3_1/recursion.out b/test/test_case/case_lab3_1/recursion.out new file mode 100644 index 0000000..9807191 --- /dev/null +++ b/test/test_case/case_lab3_1/recursion.out @@ -0,0 +1,2 @@ +8 +0 diff --git a/test/test_case/case_lab3_1/recursion.sy b/test/test_case/case_lab3_1/recursion.sy new file mode 100644 index 0000000..67a71b8 --- /dev/null +++ b/test/test_case/case_lab3_1/recursion.sy @@ -0,0 +1,10 @@ +int fib(int n) { + if (n <= 1) return n; + return fib(n-1) + fib(n-2); +} +int main() { + int n = 6; + putint(fib(n)); + putch(10); + return 0; +}