RuslanMag

Палиндром

Nov 9th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. /*
  2.     1) Проверить палиндром   
  3. */
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     const int N = 100000;
  11.     char S[N];
  12.     cin.getline(S, N);
  13.  
  14.     int a = strlen(S);
  15.  
  16.     bool ok = true;
  17.  
  18.     for (int i = 0, j = a - 1; i < j; i++, j--)
  19.     {
  20.         if (S[i] != S[j])
  21.         {
  22.             ok = false;
  23.             break;
  24.         }
  25.     }
  26.  
  27.     if (ok)
  28.     {
  29.         cout << "Yes";
  30.     }
  31.     else
  32.     {
  33.         cout << "No";
  34.     }
  35. }
Add Comment
Please, Sign In to add comment