fork(13) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(void) {
  6. int count[256][256];
  7. memset(count, 0, sizeof(count));
  8. const char *str = "xdshahaalohalobscxbsbsbs";
  9. for (const char *p = str ; *(p+1) ; p++) {
  10. count[(int)*p][(int)*(p+1)]++;
  11. }
  12. int bestA = 0, bestB = 0;
  13. for (int i = 0 ; i != 256 ; i++) {
  14. for (int j = 0 ; j != 256 ; j++) {
  15. if (count[i][j] > count[bestA][bestB]) {
  16. bestA = i;
  17. bestB = j;
  18. }
  19. }
  20. }
  21. printf("'%c%c' : %d times\n", bestA, bestB, count[bestA][bestB]);
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 1860KB
stdin
Standard input is empty
stdout
'bs' : 4 times