SHARE
TWEET

Untitled

Andoroid Oct 23rd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. void replaceAll( string &s, const string &search, const string &replace ) {
  6.     for( size_t pos = 0; ; pos += replace.length() ) {
  7.         pos = s.find( search, pos );
  8.         if( pos == string::npos ) break;
  9.         s.erase( pos, search.length() );
  10.         s.insert( pos, replace );
  11.     }
  12. }
  13.  
  14. int main() {
  15.     cout << "Введіть рядок" << "\n";
  16.     string s;
  17.     getline(cin,s);
  18.     replaceAll(s," ","");
  19.     for(int i=0;i<=s.size()/2;i++) {
  20.         if(s[i]!=s[s.size()-1-i]) {
  21.             cout << "Не паліндром";
  22.             return;
  23.         }
  24.     }
  25.     cout << "Паліндром";
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top