fork(1) download
  1. #include <iostream>
  2. #include <map>
  3. #include <cstring>
  4. #include <cstdlib>
  5. using namespace std;
  6.  
  7. int main() {
  8. map<string, int> m;
  9. string word;
  10.  
  11. while( cin >> word )
  12. m[word]++;
  13. for(map<string, int>::iterator (it) = (m).begin(); (it) != (m).end() ; (it)++)
  14. {
  15. cout<<it->first<<" - "<<it->second<<endl;
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0s 3464KB
stdin
Hey Jude, don't make it bad.
Take a sad song and make it better.
stdout
Hey - 1
Jude, - 1
Take - 1
a - 1
and - 1
bad. - 1
better. - 1
don't - 1
it - 2
make - 2
sad - 1
song - 1