Advertisement
arturParchem

czy Palindrom

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