Code:
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
int x,test;
while(test) {
bool prim[x];
cout<<" Geben sie zahl ein " << endl;
cin >>x;
prim[0]=false;
prim[1]=false;
for(int c=2;c<x;++c)
prim[c]= true;
for(int c=2; c<sqrt((double)x); c=c+1)
if (prim[c])
for (int j=2*c;j<x; j=j+c)
prim[j]=false;
for (int c=0;c<x;c=c+1)
if (prim[c]);
cout<< c << endl;
cout<<"Noch ein mall? Ja=1 Nein=0"<< endl;
cin >>test;}
return 0;
}
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
int x,test;
while(test) {
bool prim[x];
cout<<" Geben sie zahl ein " << endl;
cin >>x;
prim[0]=false;
prim[1]=false;
for(int c=2;c<x;++c)
prim[c]= true;
for(int c=2; c<sqrt((double)x); c=c+1)
if (prim[c])
for (int j=2*c;j<x; j=j+c)
prim[j]=false;
for (int c=0;c<x;c=c+1)
if (prim[c]);
cout<< c << endl;
cout<<"Noch ein mall? Ja=1 Nein=0"<< endl;
cin >>test;}
return 0;
}
Ako neko ima bolju ideju za izradu ovog programa , bicu mu zahvalan !
Hvala unapred