The next palindrome problem – https://www.spoj.com/problems/PALIN/
My code for this problem is:
#include <bits/stdc++.h>
using namespace std;
bool palinIdentifier(int in)
{
int digit = 0, n = 0, rev = 0;
n = in;
do
{
digit = in % 10;
rev = (rev * 10) + digit;
in = in/10;
}while (in != 0);
if (n == rev)
{
return true;
}else return false;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int T = 0, num = 123; bool ans;
cin >> T;
int K[T];
for (int i = 0; i < T; ++i)
{
cin >> K[i];
}
for (int i = 0; i < T; ++i)
{
for (num = K[i]+1; !palinIdentifier(num); ++num){};
cout << num << endl;
}
return 0;
}
When I test it on my pc with the given input examples it works properly.
But when I submit my solution it says Wrong Answer
WHY?!
Please help!