Advertisement
sellmmaahh

OR-2007-NajCifra

Aug 11th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1.  
  2. #include<stdio.h>
  3. #include<math.h>
  4.  
  5. int najcifra (char *s) {
  6.     int j;
  7.     int br_cifara[10];
  8.     for (j=0; j<10; j++) br_cifara[j]=0;
  9.  
  10.     while (*s!='\0') {
  11.             if (*s>='0' && *s<='9')
  12.             br_cifara[*s-'0']++;
  13.     s++;
  14.     }
  15.     int max_br=0, i, maxi;
  16.     for (i=0; i<10; i++) {
  17.             if (br_cifara[i]>max_br) {
  18.                     max_br=br_cifara[i];
  19.             maxi=i;
  20.             }}
  21.             return maxi;
  22. }
  23. int main () {
  24.     char s[]="34df421";
  25.     printf("%d",najcifra(s));
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement