fork download
  1. #include <stdio.h>
  2. #define IOVEC(s) s, (sizeof(s) - 1)
  3.  
  4. char mostFrequentCharacter(const char* str, int size)
  5. {
  6. unsigned int count[128] = { 0 };
  7. char ret = 0;
  8.  
  9. for (; size--; str++) {
  10. if (++count[*str] > count[ret]) {
  11. ret = *str;
  12. }
  13. }
  14.  
  15. return ret;
  16. }
  17.  
  18. int main(void) {
  19. printf("%c\n", mostFrequentCharacter(IOVEC("mamku tvoyu ebal")));
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 2160KB
stdin
Standard input is empty
stdout
m