Hi I ran this code on Codechef's IDE and on Codeblocks. I got answer different answers: 1001 for CODEBLOCK 818(Correct one) Codechef IDE. Please help!.
Code snipplet : http://pastie.org/10223010
#include <iostream>
#include <string>
#include<sstream>
#include<cmath>
using namespace std;
int palin(int n);
int main()
{
int i,t;
int n;
cin>>t;
for(i=0;i<t;i++){
cin>>n;
palin(n);
while(1){
n++;
if(palin(n)==1){
cout<<n<<endl;
break;
}
}
}
return 0;
}
int palin(int n){
int len=0;
int m=0;
int dum=n;
while(n!=0){
n=n/10;
len++;
}
n=dum;
while(n!=0){
m=m+((pow(10,(len-1)))*(n%10));
n=n/10;
len--;
}
if(dum==m)
return 1;
else
return 0;
}
Problem statement :http://www.codechef.com/problems/PALIN/