Skip to content

Commit c63e86f

Browse files
committed
add test codes
1 parent fa1f9c5 commit c63e86f

File tree

5 files changed

+112
-0
lines changed

5 files changed

+112
-0
lines changed

test_Code/code_generator_test-18.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
int main() {
2+
int i = 0;
3+
4+
continue;
5+
for (; i < 10; i++) {
6+
if (i % 2 == 0) {
7+
continue;
8+
}
9+
write(i);
10+
}
11+
return 0;
12+
}

test_Code/final_test-1.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
bool checkTime(time check) {
2+
if (check < 12:0:0) {
3+
return true;
4+
} else {
5+
return false;
6+
}
7+
}
8+
9+
int main() {
10+
int hour, min, sec, totalSec;
11+
time startTime;
12+
13+
read(&hour);
14+
read(&min);
15+
read(&sec);
16+
17+
read(&totalSec);
18+
19+
startTime = makeTime(hour, min, sec);
20+
21+
startTime += secToTime(totalSec);
22+
23+
write(startTime);
24+
lf();
25+
26+
if (checkTime(startTime)) {
27+
write('a');
28+
lf();
29+
} else {
30+
write('p');
31+
lf();
32+
}
33+
34+
return 0;
35+
}
36+
37+
bool checkTime(time src, time check) {
38+
if (src < check) {
39+
return true;
40+
} else {
41+
return false;
42+
}
43+
}

test_Code/final_test-2.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
int array[100] = { 0 };
2+
3+
int fibonacci(int n) {
4+
if (n < 3) {
5+
return 1;
6+
}
7+
8+
return fibonacci(n - 1) + fibonacci(n - 2);
9+
}
10+
11+
int main() {
12+
int n, i = 1;
13+
14+
read(&n);
15+
16+
for (; i <= n; i++) {
17+
array[i] = fibonacci(i);
18+
}
19+
20+
for (i = 1; i <= n; i++) {
21+
write(array[i]);
22+
}
23+
}

test_Code/final_test-3.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
int main() {
2+
int i = 0, j, in;
3+
4+
5+
read(&in);
6+
7+
for (; i < in; i++) {
8+
for (j = 0; j < in; j++) {
9+
write((float) i);
10+
}
11+
lf();
12+
}
13+
14+
lf();
15+
for (i = 0; i < in; i++) {
16+
for (j = 0; j < in; j++) {
17+
if (i > 3 && j == 3) {
18+
continue;
19+
}
20+
write(j);
21+
}
22+
lf();
23+
}
24+
25+
}

test_Code/final_test-4.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
int main() {
2+
time a = 1:1:2, b = 12:0:0;
3+
4+
write(b - a);
5+
lf();
6+
7+
write(a + b);
8+
lf();
9+
}

0 commit comments

Comments
 (0)