Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string s;
  8. getline(cin, s);
  9. map<char, int> m;
  10. for(int i = 0; i < s.size(); i++){
  11. m[s[i]]++;
  12. }
  13. for(map<char, int>::iterator it = m.begin(); it != m.end(); it++){
  14. cout<<it->first<<' '<<it->second<<endl;
  15. }
  16. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// map<pair<char, char>, int> m2;
  17. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// cout<<"comma+space:"<<endl;
  18. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// for(int i = 0; i < s.size() - 1; i++){
  19. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// m2[make_pair(s[i], s[i+1])]++;
  20. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }
  21. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// for(map<pair<char, char>, int>::iterator it = m2.begin(); it != m2.end(); it++){
  22. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// cout<<it->first.first<<it->first.second<<' '<<it->second<<endl;
  23. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }
  24. ///ЗЮЙИВЫЩМЗСЛЙЯЙЫИЖСОКЗОЪЪОНЩЙЦ ЫЗЖЪЗВЙУЬ ЫЗЫЗУЩЧОЗЖСФЧКЧ,ГЗЧМЩРЛЙЛВ
  25. char space;
  26. cin>>space;
  27. for(int i = 0 ; i < s.size() ; i++){
  28. if(s[i]==' ') s[i]='*';
  29. if(s[i]==',') s[i]='@';
  30. if(s[i]==space) s[i]=' ';
  31. }
  32. cout<<s<<endl;
  33. map<char, int> mn;
  34. for(int i = 0; i < s.size(); i++){
  35. mn[s[i]]++;
  36. }
  37. for(map<char, int>::iterator it = mn.begin(); it != mn.end(); it++){
  38. cout<<it->first<<' '<<it->second<<endl;
  39. }
  40. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement