Advertisement
Andoroid

Untitled

Oct 23rd, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement