fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <map>
  5.  
  6. int main()
  7. {
  8. int number;
  9. std::cin >> number;
  10.  
  11. std::string s = std::to_string(number);
  12. std::map<char, int> freq;
  13.  
  14. for(char ch : s) {
  15. freq[ch]++;
  16. }
  17.  
  18. std::cout << "Number Frequency\n";
  19. for(auto &elem : freq) {
  20. std::cout << std::setw(7) << std::left << elem.first << elem.second << "\n";
  21. }
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 4752KB
stdin
124243294
stdout
Number Frequency
1      1
2      3
3      1
4      3
9      1