fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. int N;
  6. scanf("%d", &N);
  7.  
  8. char s[N + 1];
  9. scanf("%s", s);
  10.  
  11. int freq[26] = {};
  12.  
  13. for (int i = 0; i < N; i++) {
  14. int index = s[i] - 'a';
  15. freq[index]++;
  16. }
  17.  
  18. for (int i = 0; i < 26; i++) {
  19. if (freq[i] != 0) {
  20. printf("%c: %d\n", 'a' + i, freq[i]);
  21. }
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty