fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. int counts[10] = {0};
  6.  
  7.  
  8. char number[1001];
  9. scanf("%1000s", number);
  10. for (int i = 0; i < strlen(number); i++) {
  11. counts[number[i] - '0']++;
  12. }
  13.  
  14.  
  15. int max_digit = 0;
  16. for (int i = 1; i < 10; i++) {
  17. if (counts[i] > counts[max_digit]) {
  18. max_digit = i;
  19. }
  20. }
  21.  
  22.  
  23. printf("%d\n", max_digit);
  24. printf(" : %d\n", counts[max_digit]);
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5284KB
stdin
15000000000000
stdout
0
 : 12