Advertisement
codegod313

Order4(3)

Nov 30th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <locale.h>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. bool isPalindrom(string s) {
  9.     for (int i = 0; i < s.size() / 2; i++) {
  10.         if (s[i] != s[s.size() - 1 - i]) {
  11.             return false;
  12.         }
  13.     }
  14.     return true;
  15. }
  16.  
  17.  
  18. int main()
  19. {
  20.     setlocale(LC_ALL, "Russian");
  21.     int n;
  22.     cout << "Введите число строк" << endl;
  23.     cin >> n;
  24.     string a[10000];
  25.     cout << "Введите строки" << endl;
  26.     rewind(stdin);
  27.     for (int i = 0; i < n; i++) {
  28.         getline(cin, a[i]);
  29.         rewind(stdin);
  30.     }
  31.     for (int i = 0; i < n; i++) {
  32.         if (isPalindrom(a[i])) {
  33.             cout << a[i] << "  - палиндром" << endl;
  34.         }
  35.         else cout << a[i] << " - не палиндром" << endl;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement