Aleksandr_Grigoryev

palindrom

Feb 17th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int i=0,length,k=0;
  6.     bool polindrom;
  7.     char x[80];
  8.     cin.get(x,80);
  9.     do
  10.     {
  11.         length = 0;
  12.         do
  13.         {
  14.             i++;
  15.             length++;
  16.         }
  17.         while ((x[i - 1] != ' ') && (x[i - 1] != '\0'));
  18.         polindrom = true;
  19.         for (int j = 0; j<length / 2; j++)
  20.             if (x[i - length + j] != x[i - j - 2])
  21.                 polindrom = false;
  22.         if (polindrom)
  23.              k++;
  24.     }
  25.     while (x[i] != '\0');
  26.     cout <<"kol-vo ="<< k;
  27.     system("pause");
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment