final tests
This commit is contained in:
parent
a18612f583
commit
a84655600d
34 changed files with 309 additions and 32 deletions
|
@ -3,34 +3,28 @@ int printf(char* format, ...);
|
|||
int main() {
|
||||
int i;
|
||||
|
||||
// For loop
|
||||
printf("For loop:\n");
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (i == 3) {
|
||||
break; // Exit the loop when i is 3
|
||||
break;
|
||||
}
|
||||
printf("%d ", i);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// While loop
|
||||
printf("While loop:\n");
|
||||
i = 0;
|
||||
while (i < 5) {
|
||||
if (i == 3) {
|
||||
break; // Exit the loop when i is 3
|
||||
break;
|
||||
}
|
||||
printf("%d ", i);
|
||||
i++;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// Do-while loop
|
||||
printf("Do-while loop:\n");
|
||||
i = 0;
|
||||
do {
|
||||
if (i == 3) {
|
||||
break; // Exit the loop when i is 3
|
||||
break;
|
||||
}
|
||||
printf("%d ", i);
|
||||
i++;
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
For loop:
|
||||
0 1 2
|
||||
While loop:
|
||||
0 1 2
|
||||
Do-while loop:
|
||||
0 1 2
|
||||
0
|
||||
|
|
|
@ -3,36 +3,33 @@ int printf(char* format, ...);
|
|||
int main() {
|
||||
int i;
|
||||
|
||||
// For loop
|
||||
printf("For loop:\n");
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (i == 3) {
|
||||
continue; // Skip the rest of the loop when i is 3
|
||||
if (i > 3) {
|
||||
continue;
|
||||
}
|
||||
printf("%d ", i);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// While loop
|
||||
printf("While loop:\n");
|
||||
i = 0;
|
||||
while (i < 5) {
|
||||
if (i == 3) {
|
||||
if (i > 3) {
|
||||
i++;
|
||||
continue; // Skip the rest of the loop when i is 3
|
||||
continue;
|
||||
}
|
||||
printf("%d ", i);
|
||||
i++;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// Do-while loop
|
||||
printf("Do-while loop:\n");
|
||||
i = 0;
|
||||
do {
|
||||
if (i == 3) {
|
||||
if (i > 3) {
|
||||
i++;
|
||||
continue; // Skip the rest of the loop when i is 3
|
||||
continue;
|
||||
}
|
||||
printf("%d ", i);
|
||||
i++;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
For loop:
|
||||
0 1 2 4
|
||||
0 1 2 3
|
||||
While loop:
|
||||
0 1 2 4
|
||||
0 1 2 3
|
||||
Do-while loop:
|
||||
0 1 2 4
|
||||
0 1 2 3
|
||||
0
|
||||
|
|
11
test/loop/do-while.c
Normal file
11
test/loop/do-while.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
int printf(char* format, ...);
|
||||
|
||||
int main() {
|
||||
int i = 0;
|
||||
do {
|
||||
printf("%d ", i);
|
||||
i++;
|
||||
} while (i < 5);
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
2
test/loop/do-while.out
Normal file
2
test/loop/do-while.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
0 1 2 3 4
|
||||
0
|
10
test/loop/for.c
Normal file
10
test/loop/for.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
int printf(char* format, ...);
|
||||
|
||||
int main() {
|
||||
int i = 0;
|
||||
for (i = 0; i < 5; i++) {
|
||||
printf("%d ", i);
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
2
test/loop/for.out
Normal file
2
test/loop/for.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
0 1 2 3 4
|
||||
0
|
11
test/loop/while.c
Normal file
11
test/loop/while.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
int printf(char* format, ...);
|
||||
|
||||
int main() {
|
||||
int i = 0;
|
||||
while (i < 5) {
|
||||
printf("%d ", i);
|
||||
i++;
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
2
test/loop/while.out
Normal file
2
test/loop/while.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
0 1 2 3 4
|
||||
0
|
Loading…
Add table
Add a link
Reference in a new issue