Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Next Pallindrome

$
0
0

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; }


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>