fork download
  1. //Q64. Find the digit that occurs the most times in an integer number.
  2. #include <stdio.h>
  3. int main() {
  4. int n, d, f[10]={0}, i, max=0, ans=0;
  5. scanf("%d",&n);
  6. while(n){
  7. d=n%10;
  8. f[d]++;
  9. n/=10;
  10. }
  11. for(i=0;i<10;i++)
  12. if(f[i]>max){ max=f[i]; ans=i; }
  13. printf("%d", ans);
  14. }
  15.  
Success #stdin #stdout 0.01s 5320KB
stdin
112233
stdout
1