This commit is contained in:
2025-04-21 00:40:30 +02:00
parent 9ccc21edde
commit b8c75fc6d3
87 changed files with 2788 additions and 99 deletions

41
S1/GdCP/testcprogram.c Normal file
View File

@@ -0,0 +1,41 @@
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 998
int *find_next(int *a) {
for (int i = 0; i < N; i++) if (a[i] != 0) return a + i;
return NULL;
}
void kill_mults(int *a, int m) {
for (int i = 0; i < N; i++) if (a[i] % m == 0) a[i] = 0;
}
int main() {
// Setup all numbers
int n[N], *c;
int p[N], r = 0;
for (int i = 0; i < N; i++) {
n[i] = i + 2;
}
while (1){
int *c = find_next(n);
if ((c = find_next()) == NULL) break;
p[r++] = *c;
kill_mults(n, *c);
}
for (int i = 0; i < r; i++) {
printf("%d ", p[i]);
}
}