Advertisement
tuki2501

PALIN_test.cpp

Dec 2nd, 2021
836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. bool isPalin(int n) {
  7.   string s = to_string(n);
  8.   for (int i = 0; i < s.size() / 2; i++) {
  9.     if (s[i] != s[s.size() - i - 1]) return false;
  10.   }
  11.   return true;
  12. }
  13.  
  14. void solve() {
  15.   int n; cin >> n;
  16.   do {
  17.     n++;
  18.   } while (!isPalin(n));
  19.   cout << n << '\n';
  20. }
  21.  
  22. signed main() {
  23.   cin.tie(0)->sync_with_stdio(0);
  24.   freopen("in" , "r", stdin );
  25.   freopen("out", "w", stdout);
  26.   int T; cin >> T;
  27.   while (T--) solve();
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement