Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <locale.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6.  
  7. int main()
  8. {
  9. //FILE *in;
  10. setlocale (LC_ALL, "Rus");
  11.  
  12. char s[10000];
  13. long int n;
  14. int* a, i, j;
  15. //in = fopen("in.txt", "rt");
  16.  
  17. printf ("Желательно ввести небольшое натуральное число: \n");
  18. gets (s);
  19.  
  20. for (i = 0; i < strlen (s); i++)
  21. if (!isdigit (s[i]))
  22. for (j = i; j < strlen (s); j ++)
  23. s[j] = s[j + 1];
  24.  
  25. if (strlen (s) > 9) printf ("Слишком большое, sosi cock))0)");
  26.  
  27. else
  28. {
  29. n = atoi (s);
  30. //printf ("\n%d", n);
  31. a = (int*) malloc (n * sizeof (long int));
  32.  
  33. for (i = 2; i < n; i++) a[i] = 1;
  34.  
  35. for (i = 2; i * i < n; i++)
  36. for (j = i; j * i < n; j ++)
  37. a[j * i] = 0;
  38.  
  39. for (i = 2; i < n; i++)
  40. if (a[i]) printf ("%10d", i);
  41. }
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement