fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. int main(){
  6. std::string t1="aaaaaaaaaabbbbbbbbbbbbcccccccddddddddddeeeeeeefffffffffghiiiiiiiii";
  7. std::string t2 = "abcddd";
  8. std::string str;
  9.  
  10. while (std::cin >> str){
  11.  
  12. std::map<char, long> M;
  13.  
  14. for (auto & o : str)M[o]++;
  15. for (auto & o : M) {
  16. std::cout << o.first;
  17. if (o.second > 1) std::cout << o.second;
  18. }
  19. str = "";
  20. std::cout << std::endl;
  21. }
  22. if (str.size() == 0){
  23. std::cout << "0";
  24. std::cout << std::endl;
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 3480KB
stdin
aaaaaaaaaabbbbbbbbbbbbcccccccddddddddddeeeeeeefffffffffghiiiiiiiii
abcddd

stdout
a10b12c7d10e7f9ghi9
abcd3
0