Cod sursa(job #2058176)

Utilizator hhhhhhhAndrei Boaca hhhhhhh Data 5 noiembrie 2017 11:26:12
Problema Ciurul lui Eratosthenes Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.35 kb
#include <fstream>

using namespace std;
int c[100],d,j,n,nr=0;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int main()
{
    fin>>n;
    c[0]=1;
    c[1]=1;
    for(int d=2;d<=n;d++)
        if(c[d]==0)
        {
            nr++;
            for(j=2;j<=n/d;j++)
                c[j*d]=1;
        }
    fout<<nr;
    return 0;
}