Advertisement
arturParchem

Czy palindrom z odwróceniem kolejności

May 13th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int pomoc=0;
  8.     string slowo, odmiana;
  9.     cout << "Podaj slowo(z malej litery)" << endl;
  10.     cin>>odmiana;
  11.     slowo = odmiana;
  12.     int d = odmiana.size();
  13.     for(int i=0;i<d/2;i++)
  14.     {
  15.         swap(odmiana[i],odmiana[d-i-1] );
  16.     }
  17.     for(int i=0;i<d;i++)
  18.     {
  19.         if(odmiana[i]==slowo[i])
  20.         {
  21.             pomoc++;
  22.         }
  23.     }
  24.     if(d/2!=pomoc)
  25.        {
  26.             cout<<"To jest palindrom";
  27.        }else
  28.             cout<<"To nie jest palindrom";
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement