Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "input2.h"
- int main() {
- int n = lese_int();
- int laenge = n-1;
- int j, *p;
- /* allocate a block of n ints */
- if ((p=(int *) malloc(laenge*sizeof(int))) == NULL){
- perror("malloc failed when allocating n ints");
- exit(1);
- }
- for (j=0; j<=laenge; j++) {
- p[j]= 1;
- }
- for (int i=0; i<=laenge; i++) {
- for (int x=2; x<=laenge; x++) {
- p[((i +2 ) * x) - 2]=0;
- }
- }
- // Mit print_prim Primzahlen ausgeben
- print_prim(p, laenge);
- /* return p to available memory pool */
- free(p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement