zadatak155

#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <cstdlib>
using namespace std;
bool prost(int a)
{ for(int x=2;x<=a/2;x++)
if(a%x==0)return false;
return true; } int main()
{
int a;
cin >> a;
stringstream ss;
ss<<a; string s; ss >> s;
int k[s.size()],h=a,br=-1;
while(h>0)
{ br++;
k[br]=h%10; h/=10; }
int d=1,o;
int c=0;
for(int x=0;x<s.size();x++)
{ d=1; o=a;
for(int y=0;y<x;y++)
d*=10; for(int y=0;y<10;y++)
{ o=a-k[x]*d; if(k[x]==y || abs(k[x]-y)!=1)continue; o+=d*y;
if(prost(o)){cout << o << endl;c++;} } }
if(c==0)cout << „NE POSTOJI“ << endl;
system(„PAUSE“);
return 0; }

Ostavite odgovor

Popunite detalje ispod ili pritisnite na ikonicu da biste se prijavili:

WordPress.com logo

Komentarišete koristeći svoj WordPress.com nalog. Odjavi se /  Promeni )

Fejsbukova fotografija

Komentarišete koristeći svoj Facebook nalog. Odjavi se /  Promeni )

Povezivanje sa %s