Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- void replaceAll( string &s, const string &search, const string &replace ) {
- for( size_t pos = 0; ; pos += replace.length() ) {
- pos = s.find( search, pos );
- if( pos == string::npos ) break;
- s.erase( pos, search.length() );
- s.insert( pos, replace );
- }
- }
- int main() {
- cout << "Введіть рядок" << "\n";
- string s;
- getline(cin,s);
- replaceAll(s," ","");
- for(int i=0;i<=s.size()/2;i++) {
- if(s[i]!=s[s.size()-1-i]) {
- cout << "Не паліндром";
- return;
- }
- }
- cout << "Паліндром";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement