HariboteOS/day28/app/sosu.c
2021-06-01 21:15:52 +08:00

28 lines
370 B
C

#include <stdio.h>
#include "api.h"
#define MAX 1000
int main() {
char flag[MAX], s[8];
for (int i = 0; i < MAX; i++) {
flag[i] = 0;
}
for (int i = 2; i < MAX; i++) {
if (flag[i] == 0) {
sprintf(s, "%d ", i);
api_putstr(s);
for (int j = 1 * 2; j < MAX; j += i) {
flag[j] = 1;
}
}
}
api_end();
return 0;
}