Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Liczby pierwsze by troyaax
- #include <conio.h>
- #include <cstdio>
- #include <cmath>
- int main()
- {
- int zakres;
- printf ("Podaj zakres: \n");
- scanf("%d", &zakres);
- int f=zakres/2;
- bool m[zakres];
- for(int n=0;n<zakres;n++) m[n]=1;
- for(int k=2;k<f;k++)
- if(m[k]) for(int j=k+k;j<zakres;j+=k) m[j]=0;
- for(int i=2;i<zakres;i++)
- {
- if(m[i])
- {
- printf("%d ", i);
- }
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment