1 / 2
Mar 2015

include

include

using namespace std;
string str;int t,flag,temp;
int main()
{
int check(long);
int palin(string);
cin>>t;
long arr[t];
for(int i=0;i {
cin>>arr[i];
}
for(int i=0;i {
temp=arr[i];
flag=check(arr[i]);
cout< }
}
int check(long num)
{
int palin(string);
int con=0,n=2;
while(con!=1)
{
str="";
num=temp;
while(num>0)
{
str=to_string(num%n)+str;
num=num/n;
}
con=palin(str);
n++;
}
return --n;
}
int palin(string st)
{
int tr=1,l=st.length()-1;
for(int i=0;i<=l;i++)
{
if(st[i]!=str[l-i])
{
tr=0;
break;
}
}
return tr;
}

It says that to_string is not declaerd. Well i used the string header file, so what's wrong??

  • created

    Mar '15
  • last reply

    Mar '15
  • 1

    reply

  • 329

    views

  • 2

    users

Please use code tags when posting code.

to_string is only in C++11. What compiler did you use to submit? I haven't used C++11 yet on SPOJ so I don't even know if it will work.

What's the largest value that can fit in long?

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 14 6d

Want to read more? Browse other topics in C and C++ or view latest topics.