Răspuns :
#include <iostream>
using namespace std;
int og(int n){
int og=0;
while(n){
og=og*10+n%10;
n/=10;
}
return og;
}
bool isprim(int n){
if (n==2) return true;
else if(n%2==0 or n<2) return false;
for(int d=3;d*d<=n;d+=2){
if(n%d==0) return false;
}
return true;
}
int main(){
for(int i=101;i<=999;i+=2){
if(isprim(i)==1 and isprim(og(i))) cout<<i<<" ";
}
return 0;
}
Sper ca te-am ajutat!
Răspuns:
#include <iostream>
using namespace std;
int main()
{
int i,j,j1,c,nr=0,x,k,b;
for(j=100;j<=999;j++)
{
nr=0;
k=0;
b=0;
for(i=2;i<=j/2;i++)
{
if(j%i==0)
{
k++;
}
}
if(k==0)
{
j1=j;
while(j1!=0)
{
c=j1%10;
j1=j1/10;
nr=nr*10+c;
}
for(x=2;x<=nr/2;x++)
{
if(nr%x==0)
{
b++;
}
}
if(b==0)
{
cout<<nr<<"="<<j<<" ";
}
}
}
}
Programul a fost testat:
Explicație: