UVA 10235 - Simply Emirp Solution
UVA 10235 - Simply Emirp Solution /* It is a simple and easy problem. But has critical test case. Critical case: If a number is prime and reverse number is equal to the given number then the output is "prime" not "emirp". For example: Given number 11. 11 number is prime. But reverse number is also 11.So, it is not "emirp". It is prime. */ Code: #include<iostream> #include<string> #include<string.h> #include<algorithm> #define MAX 1000001 using namespace std; bool prime[MAX]; int reverseInt(int num) { string str=to_string(num); reverse(str.begin(),str.end()); num=stoi(str); return num; } int main() { int i,j,x; memset(prime,1,sizeof(prime)); for(i=4;i<MAX;i+=2) prime[i]=0; for(i=3;i<1001;i+=2) { ...