Guest User

Untitled

a guest
Oct 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. using namespace std;
  4. void imprimeVec(int v[]);
  5.  
  6. int main()
  7. {
  8. cout<<"LA COLADERA DE ERATOSTENES\n";
  9. cout<<"Solo numeros primos antes de 1000\n";
  10. int v[999];
  11. for(int i=0;i<1000;i++)
  12. v[i]=1;
  13. for(int i=2;i<1000;i++)
  14. for(int x=i+1;x<1000;x++)
  15. if (x%i==0)
  16. v[x]=0;
  17. imprimeVec(v);
  18.  
  19. return 0;
  20. }
  21. void imprimeVec(int v[])
  22. {
  23. for(int i=0;i<1000;i++)
  24. if(v[i] == 1) cout<<i<<"\n";
  25. }
Add Comment
Please, Sign In to add comment