1
1
mirror of https://github.com/foxsen/archbase.git synced 2026-04-13 17:50:22 +08:00

initial import to public repository

This commit is contained in:
Zhang Fuxin
2021-10-27 19:14:51 +08:00
commit c632bed67e
362 changed files with 53748 additions and 0 deletions

36
materials/chapter2/loop.c Normal file
View File

@@ -0,0 +1,36 @@
int test_for(int a) {
int sum = 0;
int i = 0;
for (i = 0; i < a; i++) {
sum += i;
}
return sum;
}
int test_while(int a) {
int sum = 0;
int i = 0;
while (i < a) {
sum += i;
i++;
}
return sum;
}
int test_dowhile(int a) {
int sum = 0;
int i = 0;
do {
sum += i;
i++;
} while (i < a);
return sum;
}