Advertisement
sellmmaahh

OR-2007-NajSlovo

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