Skip to content
This repository was archived by the owner on Aug 7, 2022. It is now read-only.

Commit bef2cf0

Browse files
author
tinsir888
authored
Add files via upload
1 parent b433ce6 commit bef2cf0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1204
-0
lines changed

test/level1-2/012_func_defn.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9

test/level1-2/012_func_defn.sy

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
int a;
2+
int func(int p){
3+
p = p - 1;
4+
return p;
5+
}
6+
int main(){
7+
int b;
8+
a = 10;
9+
b = func(a);
10+
return b;
11+
}

test/level1-2/013_var_defn_func.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4

test/level1-2/013_var_defn_func.sy

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
int defn(){
2+
return 4;
3+
}
4+
5+
int main(){
6+
int a=defn();
7+
return a;
8+
}

test/level1-2/028_if_test1.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
25

test/level1-2/028_if_test1.sy

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// test if-else
2+
int ifElse() {
3+
int a;
4+
a = 5;
5+
if (a == 5) {
6+
a = 25;
7+
} else {
8+
a = a * 2;
9+
}
10+
return (a);
11+
}
12+
13+
14+
int main() {
15+
return (ifElse());
16+
}

test/level1-2/029_if_test2.out

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-5
2+
0

test/level1-2/029_if_test2.sy

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// test if-else-if
2+
int ifElseIf() {
3+
int a;
4+
a = 5;
5+
int b;
6+
b = 10;
7+
if(a == 6 || b == 0xb) {
8+
return a;
9+
}
10+
else {
11+
if (b == 10 && a == 1)
12+
a = 25;
13+
else if (b == 10 && a == -5)
14+
a = a + 15;
15+
else
16+
a = -+a;
17+
}
18+
19+
return a;
20+
}
21+
22+
int main(){
23+
putint(ifElseIf());
24+
return 0;
25+
}

test/level1-2/030_if_test3.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
25

test/level1-2/030_if_test3.sy

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// test if-if-else
2+
int ififElse() {
3+
int a;
4+
a = 5;
5+
int b;
6+
b = 10;
7+
if(a == 5)
8+
if (b == 10)
9+
a = 25;
10+
else
11+
a = a + 15;
12+
13+
return (a);
14+
}
15+
16+
int main(){
17+
return (ififElse());
18+
}

test/level1-2/031_if_test4.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
25

test/level1-2/031_if_test4.sy

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// test if-{if-else}
2+
int if_ifElse_() {
3+
int a;
4+
a = 5;
5+
int b;
6+
b = 10;
7+
if(a == 5){
8+
if (b == 10)
9+
a = 25;
10+
else
11+
a = a + 15;
12+
}
13+
return (a);
14+
}
15+
16+
int main(){
17+
return (if_ifElse_());
18+
}

test/level1-2/032_if_test5.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
25

test/level1-2/032_if_test5.sy

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// test if-{if}-else
2+
int if_if_Else() {
3+
int a;
4+
a = 5;
5+
int b;
6+
b = 10;
7+
if(a == 5){
8+
if (b == 10)
9+
a = 25;
10+
}
11+
else
12+
a = a + 15;
13+
return (a);
14+
}
15+
16+
int main(){
17+
return (if_if_Else());
18+
}

test/level1-2/035_while_test2.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
54

test/level1-2/035_while_test2.sy

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
int FourWhile() {
2+
int a;
3+
a = 5;
4+
int b;
5+
int c;
6+
b = 6;
7+
c = 7;
8+
int d;
9+
d = 10;
10+
while (a < 20) {
11+
a = a + 3;
12+
while(b < 10){
13+
b = b + 1;
14+
while(c == 7){
15+
c = c - 1;
16+
while(d < 20){
17+
d = d + 3;
18+
}
19+
d = d - 1;
20+
}
21+
c = c + 1;
22+
}
23+
b = b - 2;
24+
}
25+
26+
return (a + (b + d) + c);
27+
}
28+
29+
int main() {
30+
return FourWhile();
31+
}

test/level1-2/036_while_test3.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
23

test/level1-2/036_while_test3.sy

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
int g;
2+
int h;
3+
int f;
4+
int e;
5+
int EightWhile() {
6+
int a;
7+
a = 5;
8+
int b;
9+
int c;
10+
b = 6;
11+
c = 7;
12+
int d;
13+
d = 10;
14+
while (a < 20) {
15+
a = a + 3;
16+
while(b < 10){
17+
b = b + 1;
18+
while(c == 7){
19+
c = c - 1;
20+
while(d < 20){
21+
d = d + 3;
22+
while(e > 1){
23+
e = e-1;
24+
while(f > 2){
25+
f = f -2;
26+
while(g < 3){
27+
g = g +10;
28+
while(h < 10){
29+
h = h + 8;
30+
}
31+
h = h-1;
32+
}
33+
g = g- 8;
34+
}
35+
f = f + 1;
36+
}
37+
e = e + 1;
38+
}
39+
d = d - 1;
40+
}
41+
c = c + 1;
42+
}
43+
b = b - 2;
44+
}
45+
46+
return (a + (b + d) + c)-(e + d - g + h);
47+
}
48+
49+
int main() {
50+
g = 1;
51+
h = 2;
52+
e = 4;
53+
f = 6;
54+
return EightWhile();
55+
}

test/level1-2/039_while_if_test1.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
198

test/level1-2/039_while_if_test1.sy

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// test while-if
2+
int whileIf() {
3+
int a;
4+
a = 0;
5+
int b;
6+
b = 0;
7+
while (a < 100) {
8+
if (a == 5) {
9+
b = 25;
10+
}
11+
else if (a == 10) {
12+
b = 42;
13+
}
14+
else {
15+
b = a * 2;
16+
}
17+
a = a + 1;
18+
}
19+
return (b);
20+
}
21+
22+
23+
int main(){
24+
return (whileIf());
25+
}

test/level1-2/040_while_if_test2.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
96

test/level1-2/040_while_if_test2.sy

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
int ifWhile() {
2+
int a;
3+
a = 0;
4+
int b;
5+
b = 3;
6+
if (a == 5) {
7+
while(b == 2){
8+
b = b + 2;
9+
}
10+
b = b + 25;
11+
}
12+
else
13+
while (a < 5) {
14+
b = b * 2;
15+
a = a + 1;
16+
}
17+
return (b);
18+
}
19+
20+
21+
int main(){
22+
return (ifWhile());
23+
}

test/level1-2/041_while_if_test3.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
88

test/level1-2/041_while_if_test3.sy

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
int deepWhileBr(int a, int b) {
2+
int c;
3+
c = a + b;
4+
while (c < 75) {
5+
int d;
6+
d = 42;
7+
if (c < 100) {
8+
c = c + d;
9+
if (c > 99) {
10+
int e;
11+
e = d * 2;
12+
if (1 == 1) {
13+
c = e * 2;
14+
}
15+
}
16+
}
17+
}
18+
return (c);
19+
}
20+
21+
int main() {
22+
int p;
23+
p = 2;
24+
return deepWhileBr(p, p);
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
91 39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
13
2+
0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
int fun(int m,int n){
2+
int rem;
3+
while(n > 0){
4+
rem = m % n;
5+
m = n;
6+
n = rem;
7+
}
8+
return m;
9+
}
10+
int main(){
11+
int n,m;
12+
int num;
13+
m=getint();
14+
n=getint();
15+
num=fun(m,n);
16+
putint(num);
17+
18+
return 0;
19+
}

test/level1-2/100_int_literal.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
230

test/level1-2/100_int_literal.sy

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
int s = 0;
2+
3+
int get_ans_se(int ans, int v0, int v1) {
4+
int v = 0;
5+
if (v0 == v1) v = 1;
6+
ans = ans * 2;
7+
ans = ans + v;
8+
s = s + ans;
9+
return ans;
10+
}
11+
12+
int get_ans(int ans, int v0, int v1) {
13+
int v = 0;
14+
if (v0 == v1) v = 1;
15+
ans = ans * 2;
16+
ans = ans + v;
17+
return ans;
18+
}
19+
20+
int main() {
21+
const int k0 = -2147483648;
22+
const int k1 = 0x80000000;
23+
const int k2 = 0x80000000 + 1;
24+
const int k3 = 0x7fFffffF;
25+
const int k4 = 0x7fFffffF - 1;
26+
int a1, a2, a3, a4;
27+
a1 = get_ans( 0, k0, k1);
28+
a1 = get_ans(a1, k0 + 1, k2);
29+
a1 = get_ans(a1, k0, -k3 - 1);
30+
a1 = get_ans(a1, k0, k4 + 1);
31+
a1 = get_ans(a1, k1 / 2, k2 / 2);
32+
a1 = get_ans(a1, k1, -k3 - 1);
33+
a1 = get_ans(a1, k1, k4 + 1);
34+
a2 = get_ans( 0, k2, k3);
35+
a2 = get_ans(a2, k2, k4);
36+
a2 = get_ans(a2, k3, k4);
37+
a2 = get_ans(a2, k0 / 2, k1 / 2);
38+
a3 = get_ans_se( 0, k0, k1);
39+
a3 = get_ans_se(a3, k0 + 1, k2);
40+
a3 = get_ans_se(a3, k0, -k3 - 1);
41+
a3 = get_ans_se(a3, k0, k4 + 1);
42+
a3 = get_ans_se(a3, k1 / 2, k2 / 2);
43+
a3 = get_ans_se(a3, k1, -k3 - 1);
44+
a3 = get_ans_se(a3, k1, k4 + 1);
45+
a4 = get_ans_se( 0, k2, k3);
46+
a4 = get_ans_se(a4, k2, k4);
47+
a4 = get_ans_se(a4, k3, k4);
48+
a4 = get_ans_se(a4, k0 / 2, k1 / 2);
49+
return a1 + a2 + a3 + a4;
50+
}

test/level1-2/102_short_circuit3.out

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
0 3 0 3
2+
3 3
3+
ADF
4+
CIJK
5+
0

0 commit comments

Comments
 (0)