fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. string s;
  6. cin >> s;
  7.  
  8. int tab[26];
  9. for(int i=0; i<26; i++) {
  10. tab[i] = 0;
  11. }
  12.  
  13. for(int i=0; i<s.size(); i++) {
  14. int numer = s[i]-'a';
  15. tab[numer]++;
  16. }
  17.  
  18. for(int i=0; i<26; i++) {
  19. if(tab[i]>0) {
  20. cout << (char)('a'+i) << " " << tab[i] << "\n";
  21. }
  22. }
  23.  
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5300KB
stdin
ananas
stdout
a 3
n 2
s 1