Advertisement
InnaSibirova

Palindrom

Oct 5th, 2021
788
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main() {
  5.     int n, a, c =10, flag = 1, size = 0;
  6.     cin >>  n;
  7.     while(n / c != 0) {
  8.         size++;
  9.         c *= 10;
  10.     }
  11.     for(int i = 1; i <= size; i++) {
  12.         c = int(pow(10, i));
  13.         a = int(pow(10, size  - i));
  14.         if((n / c) % 10 != (n / a) % 10) {
  15.             flag = 0;
  16.         }
  17.     }
  18.     if(flag == 1) {
  19.         cout << "YES";
  20.     }
  21.     else {
  22.         cout << "NO";
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement