fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4. using namespace std;
  5.  
  6. int main() {
  7. string s;
  8. getline(cin, s);
  9. int seen['z'-'a'+1] {0};
  10. for (int i = 0 ; i != s.size() ; i++) {
  11. char ch = s[i];
  12. if (!islower(ch))
  13. continue;
  14. seen[ch-'a']++;
  15. }
  16. for (int i = 0 ; i != 'z'-'a'+1 ; i++) {
  17. if (seen[i]) {
  18. cout << (char)('a'+i) << " - " << seen[i] << endl;
  19. }
  20. }
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3464KB
stdin
quick brown fox jumps over
stdout
b - 1
c - 1
e - 1
f - 1
i - 1
j - 1
k - 1
m - 1
n - 1
o - 3
p - 1
q - 1
r - 2
s - 1
u - 2
v - 1
w - 1
x - 1