aboutsummaryrefslogtreecommitdiff
path: root/rcc-legacy/tests/sysy_lvX/090_int_io.sy
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-06-08 17:10:31 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-06-08 17:10:31 +0800
commit72af0dedf9e18911da65b9a5c4906689e868d9fc (patch)
tree2ecbad93f96ab8ad7e26dc02cd02d802f853ab97 /rcc-legacy/tests/sysy_lvX/090_int_io.sy
parent8faf6d290d6703b1775e0ad7a8928a4ebea4b11b (diff)
downloadrcc-project-72af0dedf9e18911da65b9a5c4906689e868d9fc.tar.gz
rcc-project-72af0dedf9e18911da65b9a5c4906689e868d9fc.tar.xz
[legacy] Add functional and performance test suites
Diffstat (limited to 'rcc-legacy/tests/sysy_lvX/090_int_io.sy')
-rw-r--r--rcc-legacy/tests/sysy_lvX/090_int_io.sy53
1 files changed, 53 insertions, 0 deletions
diff --git a/rcc-legacy/tests/sysy_lvX/090_int_io.sy b/rcc-legacy/tests/sysy_lvX/090_int_io.sy
new file mode 100644
index 0000000..1593dfc
--- /dev/null
+++ b/rcc-legacy/tests/sysy_lvX/090_int_io.sy
@@ -0,0 +1,53 @@
+const int ascii_0 = 48;
+
+int my_getint()
+{
+ int sum = 0, c;
+
+ while (1) {
+ c = getch() - ascii_0;
+ if (c < 0 || c > 9) {
+ continue;
+ } else {
+ break;
+ }
+ }
+ sum = c;
+
+ while (1) {
+ c = getch() - ascii_0;
+ if (c >= 0 && c <= 9) {
+ sum = sum * 10 + c;
+ } else {
+ break;
+ }
+ }
+
+ return sum;
+}
+
+void my_putint(int a)
+{
+ int b[16], i = 0;
+ while (a > 0) {
+ b[i] = a % 10 + ascii_0;
+ a = a / 10;
+ i = i + 1;
+ }
+ while (i > 0) {
+ i = i - 1;
+ putch(b[i]);
+ }
+}
+
+int main()
+{
+ return 0;
+ // int n = my_getint();
+ // while (n > 0) {
+ // int m = my_getint();
+ // my_putint(m); putch(10);
+ // n = n - 1;
+ // }
+ // return 0;
+}