fork download
  1. #include <locale>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <iterator>
  5. #include <vector>
  6. #include <sstream>
  7. #include <string>
  8. #include <map>
  9.  
  10. class my_ctype : public
  11. std::ctype<char>
  12. {
  13. mask my_table[table_size];
  14. public:
  15. my_ctype(size_t refs = 0)
  16. : std::ctype<char>(&my_table[0], false, refs)
  17. {
  18. std::copy_n(classic_table(), table_size, my_table);
  19. my_table['-'] = (mask)space;
  20. my_table['\''] = (mask)space;
  21. my_table['.'] = (mask)space;
  22. my_table[','] = (mask)space;
  23. my_table[';'] = (mask)space;
  24. my_table[':'] = (mask)space;
  25. my_table['!'] = (mask)space;
  26. my_table['!'] = (mask)space;
  27. }
  28. };
  29.  
  30. int main() {
  31. std::istringstream input("yoba,batya;batya-pidor!krestoblyad");
  32. std::locale x(std::locale::classic(), new my_ctype);
  33. input.imbue(x);
  34. std::map<std::string, int> dict;
  35.  
  36. while (input.good()) {
  37. std::string s;
  38. input >> s;
  39. dict[s]++;
  40. }
  41.  
  42. for (auto s : dict) {
  43. std::cout << s.first << ":" << s.second << std::endl;
  44. }
  45.  
  46. return 0;
  47. }
  48.  
Success #stdin #stdout 0s 3480KB
stdin
Standard input is empty
stdout
batya:2
krestoblyad:1
pidor:1
yoba:1