Guest User

Untitled

a guest
May 21st, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5.  
  6. void swap (char& a, char& b) {
  7.     char c = a;
  8.     a = b;
  9.     b = c;
  10. }
  11.  
  12. string gira(string s) {
  13.     int n = s.size();
  14.     for (int i = 0; i < n/2; ++i) {
  15.         swap(s[i], s[(n-1)-i]);
  16.     }  
  17.     return s;
  18. }
  19.  
  20. bool son_iguals(string s1, string s2) {
  21.    
  22.     int n = s1.size();
  23.     string s3 = gira(s1);
  24.            
  25.     for (int i = 0; i < n; ++i) {
  26.         if (s1[i] != s2[i] and s3[i] != s2[i]) return false;
  27.     }
  28.     return true;
  29. }
  30.  
  31. int main() {
  32.    
  33.     string s1, s2;
  34.    
  35.     while (cin >> s1 and cin >> s2) {
  36.         if (son_iguals(s1, s2)) cout << "yes" << endl;
  37.         else cout << "no" << endl;
  38.     }
  39. }
Add Comment
Please, Sign In to add comment