Can, anybody help me this code of next pallindrome given below. Problem link:http://www.codechef.com/problems/PALIN
It works for the test cases but is not accepted by the judge.
include<iostream>
using namespace std;
int reverse(int k) { int ans=0; while(k>0) { ans=ans*10+k%10; k=k/10; } return ans; }
int func(int k) { int rev; while(1) { k++; rev=reverse(k); if(rev==k) break;
}
return rev;
}
int main() { int t; cin>>t; while(t--){ int k; cin>>k; cout<<func(k)<<endl;} return 0; }