Cod sursa(job #399391)
Utilizator | Data | 20 februarie 2010 13:57:33 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include<fstream.h>
ifstream f("ciur.in");
ofstream g("ciur.out");
int main()
{int x[1000],n,j,i,nr=0;
f>>n;
for(i=2;i<=n;i++)
x[i]=1;
for(i=2;i<=n;i++)
if(x[i]==1) {nr++;
for(j=i+i;j<=n;j+=i)
x[j]=0;
}
g<<nr;
return 0;
}