First off, here is my code:
#include <bits/stdc++.h>
using namespace std;
bool palinIdentifier(int in) // Function which reverses the input number and checks if its a palindrom or not
{
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 = 0; // Initializing T(which is the number of test cases i.e. the number of inputs)
// and num which is used later to temporarly store K[i]
bool ans;
cin >> T;
int K[T]; // An array which will contain all the inputs
for (int i = 0; i < T; ++i) // Taking all the inputs
{
cin >> K[i];
}
for (int i = 0; i < T; ++i) // Checking and printing what is required
{
for (num = K[i]+1; !palinIdentifier(num); ++num){};
cout << num << endl;
}
return 0;
}
And here is the problem: https://www.spoj.com/problems/PALIN/
When I try to run the example Inputs given, it works as it is supposed to. BUT When I try to submit my solution, the code judge outputs wrong answer. It would be great if someone could tell me why this is happening and what is wrong with my code.
Thanks a lot!
Aucun commentaire:
Enregistrer un commentaire