Count a number of times indicated in each letter string appearing in the string (not case sensitive when statistics), and the maximum number of the letters appears output (if more than one, can output a)

#include <stdio.h> 
#include <string.h> 
void Fun (A char []) 
{int B [26 is], I, n-, max; 
   for (I = 0; I <26 is; I ++) 
      A [I ] = 0; 
   n-= strlen (A); 
   for (I = 0; I <n-; I ++) 
      IF (A [I]> = 'A' && A [I] <= 'Z') 
         B [A [I ] - 'A'] ++; 
      the else IF (A [I]> = 'A' && A [I] <= 'the Z') 
         B [A [I] -'A '] ++; 
   max = 0; 
   for (I =. 1; I <26 is; I ++) 
     IF (B [max] <B [I]) 
       max = I; max the highest number of the subscript assigned to the // appears 
   printf ( "the largest number of characters appear are: C% \ n-', max +' a '); 
} 
main () 
{char a [200 is]; 
   the printf ( "enter a string to be counted:");scanf("%s", a);
   fun(a);
}

  

Guess you like

Origin www.cnblogs.com/-slz-2/p/11275376.html