Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. using namespace std;
  6. void small(string &a) {
  7.     for (int i = 0; i < a.size(); ++i) {
  8.         if ('A' <= a[i] && a[i] <= 'Z') {
  9.             a[i] = a[i] - 'A' + 'a';
  10.         }
  11.     }
  12. }
  13. int main() {
  14.     string a;
  15.     string b;
  16.     getline(cin, a);
  17.     getline(cin, b);
  18.     vector <char> ac;
  19.     vector <char> bc;
  20.     small(a);
  21.     small(b);
  22.     sort(a.begin(), a.end());
  23.     sort(b.begin(), b.end());
  24.  
  25.     for (int i = 0; i < a.size(); ++i) {
  26.         if (i > 0) {
  27.             if (a[i] == ' ') {
  28.             }
  29.             else if (a[i] != a[i - 1]) {
  30.                 ac.push_back(a[i]);
  31.             }
  32.         }
  33.         else {
  34.             ac.push_back(a[i]);
  35.         }
  36.     }
  37.     for (int i = 0; i < b.size(); ++i) {
  38.         if (i > 0) {
  39.             if (b[i] == ' ') {
  40.             }
  41.             if (b[i] != b[i - 1]) {
  42.                 bc.push_back(b[i]);
  43.             }
  44.         }
  45.         else {
  46.             bc.push_back(b[i]);
  47.         }
  48.     }
  49.  
  50.  
  51.     for (int i = 0; i < ac.size(); ++i) {
  52.         cout << ac[i];
  53.     }
  54.     cout << endl;
  55.     for (int i = 0; i < bc.size(); ++i) {
  56.         cout << bc[i];
  57.     }
  58.     cout << endl;
  59.     if (ac == bc) {
  60.         cout << "YES";
  61.     }
  62.     else {
  63.         cout << "NO";
  64.     }
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement