fork download
  1. #include<iostream>
  2. #include<string>
  3. #include<sstream>
  4. #include<math.h>
  5. using namespace std;
  6. bool palindrom (string n)
  7. {
  8. long b;
  9. b = n.length();
  10.  
  11. for (long i=0; i<b/2+1; i++)
  12. {
  13. if (n[i]==n[b-1-i])
  14. {
  15. if (i==b-1-i)
  16. {
  17. return true;
  18. }
  19. }
  20. else return false;
  21. }
  22. }
  23.  
  24. int main()
  25. {
  26. long n;
  27. cin >> n;
  28. long test;
  29. for (long i=0; i<n; i++)
  30. {
  31. cin >> test;
  32. if (test<10000000)
  33. {
  34. for (long j=1; ;j++)
  35. {
  36. long kolejna = test + j;
  37. ostringstream ss;
  38. ss << kolejna;
  39. string str = ss.str();
  40. if (palindrom(str)==1)
  41. {
  42. cout << kolejna;
  43. break;
  44. }
  45. }
  46. }
  47. }
  48. }
Success #stdin #stdout 0s 4568KB
stdin
Standard input is empty
stdout
Standard output is empty