fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. map<string, int> mp;
  5. string s;
  6.  
  7. int main()
  8. {
  9. #define name "Bai4"
  10. if(fopen(name".inp", "r"))
  11. {
  12. freopen(name".inp", "r", stdin);
  13. freopen(name".out", "w", stdout);
  14. }
  15. ios_base::sync_with_stdio(0);
  16. cin.tie(0), cout.tie(0);
  17.  
  18. while(cin >> s){
  19. mp[s]++;
  20. }
  21. for(pair<string, int> it : mp)
  22. {
  23. cout << it.first << ' ' << it.second << '\n';
  24. }
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5304KB
stdin
Tin hoc Tuan Hung co anh Tuan Hung day hoc lap trinh
stdout
Hung 2
Tin 1
Tuan 2
anh 1
co 1
day 1
hoc 2
lap 1
trinh 1