Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- void imprimeVec(int v[]);
- int main()
- {
- cout<<"LA COLADERA DE ERATOSTENES\n";
- cout<<"Solo numeros primos antes de 1000\n";
- int v[999];
- for(int i=0;i<1000;i++)
- v[i]=1;
- for(int i=2;i<1000;i++)
- for(int x=i+1;x<1000;x++)
- if (x%i==0)
- v[x]=0;
- imprimeVec(v);
- return 0;
- }
- void imprimeVec(int v[])
- {
- for(int i=0;i<1000;i++)
- if(v[i] == 1) cout<<i<<"\n";
- }
Add Comment
Please, Sign In to add comment