Cod sursa(job #229593)
Utilizator | Data | 10 decembrie 2008 19:40:38 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream.h>
#define fin "ciur.in"
#define fout "ciur.out"
int main()
{ long n;
int a,b,c,k=0,ok=0;
ifstream in(fin);
in>>n;
for (a=3;a<=n;a+=2)
{ for (b=2; b<=a/2; b++)
ok=0;
{ if (a%b==0) {ok=1; break;} }
if (ok==0) k++;
else continue;
}
ofstream out(fout);
out<<k;
in.close ();
out.close();
return 0;
}