fork download
  1. #include <inttypes.h>
  2. #include <limits.h>
  3. #include <stdio.h>
  4.  
  5. int main(void)
  6. {
  7. // count chars
  8. uintmax_t freq[1u << CHAR_BIT] = {0};
  9. for (int c; (c = getchar()) != EOF; )
  10. ++freq[(unsigned char)c];
  11.  
  12. // print brackets' frequencies
  13. const unsigned char bracket[] = "{}()[]<>";
  14. for (size_t i = 0; i < sizeof bracket; ++i)
  15. if (freq[bracket[i]])
  16. printf("%c -> %ju\n", bracket[i], freq[bracket[i]]);
  17.  
  18. return !feof(stdin); // success on eof
  19. }
  20.  
Success #stdin #stdout 0s 9432KB
stdin
(ab)
stdout
( -> 1
) -> 1