Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. void m(const string& a, map<char, int> &a1) {
  9.     for (int i = 0; i < a.size(); ++i) {
  10.         ++a1[a[i]];
  11.     }
  12. }
  13.  
  14. int main() {
  15.     string a;
  16.     getline(cin, a);
  17.     string b;
  18.     getline(cin, b);
  19.     map<char, int> a1;
  20.     map<char, int> b1;
  21.     m(a, a1);
  22.     m(b, b1);
  23.     cout << "first string" << endl;
  24.     for (auto it = a1.begin(); it != a1.end(); ++it) {
  25.         cout << it->first << " : " << it->second << endl;
  26.     }
  27.     cout << "second string"<< endl;
  28.     for (auto it = b1.begin(); it != b1.end(); ++it) {
  29.         cout << it->first << " : " << it->second << endl;
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement