Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool checkPalindrome(long);
- int main()
- {
- int t;
- long *n = new long[t];
- cin >> t;
- for(int i = 0; i < t; i++)
- cin >> n[i];
- for(int i = 0; i < t; i++){
- long j = n[i];
- while(j++){
- if(checkPalindrome(j)){
- cout << j << endl;
- break;
- }
- }
- }
- delete []n;
- return 0;
- }
- bool checkPalindrome(long l)
- {
- bool check = false;
- long x = l, s = 0;
- do {
- int a = x%10;
- x = x/10;
- s=10*s+a;
- } while(x!=0);
- if(s == l)
- check = true;
- return check;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement