fork(2) download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4.  
  5.  
  6. int main() {
  7. std::map<std::string, int> dictionary;
  8.  
  9. for (std::string token; std::cin >> token; ) {
  10. ++dictionary[token];
  11. }
  12.  
  13. for (auto const& pair : dictionary) {
  14. std::cout << pair.first << ' ' << pair.second << std::endl;
  15. }
  16. }
Success #stdin #stdout 0s 3480KB
stdin
Split asdasdad me by whitespaces Split split hello hello hello
stdout
Split 2
asdasdad 1
by 1
hello 3
me 1
split 1
whitespaces 1