Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool checkPalindrome(long);
  6.  
  7. int main()
  8. {
  9. int t;
  10. long *n = new long[t];
  11. cin >> t;
  12. for(int i = 0; i < t; i++)
  13. cin >> n[i];
  14. for(int i = 0; i < t; i++){
  15. long j = n[i];
  16. while(j++){
  17. if(checkPalindrome(j)){
  18. cout << j << endl;
  19. break;
  20. }
  21. }
  22. }
  23. delete []n;
  24. return 0;
  25. }
  26.  
  27. bool checkPalindrome(long l)
  28. {
  29. bool check = false;
  30.  
  31. long x = l, s = 0;
  32. do {
  33. int a = x%10;
  34. x = x/10;
  35. s=10*s+a;
  36. } while(x!=0);
  37.  
  38. if(s == l)
  39. check = true;
  40.  
  41. return check;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement