Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <locale.h>
- #include <ctype.h>
- #include <string.h>
- int main()
- {
- //FILE *in;
- setlocale (LC_ALL, "Rus");
- char s[10000];
- long int n;
- int* a, i, j;
- //in = fopen("in.txt", "rt");
- printf ("Желательно ввести небольшое натуральное число: \n");
- gets (s);
- for (i = 0; i < strlen (s); i++)
- if (!isdigit (s[i]))
- for (j = i; j < strlen (s); j ++)
- s[j] = s[j + 1];
- if (strlen (s) > 9) printf ("Слишком большое, sosi cock))0)");
- else
- {
- n = atoi (s);
- //printf ("\n%d", n);
- a = (int*) malloc (n * sizeof (long int));
- for (i = 2; i < n; i++) a[i] = 1;
- for (i = 2; i * i < n; i++)
- for (j = i; j * i < n; j ++)
- a[j * i] = 0;
- for (i = 2; i < n; i++)
- if (a[i]) printf ("%10d", i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement