Character Statistics 2 Time limit:1000ms Memory limit:65536k Title Description
Enter an English sentence that outputs the most frequently occurring characters in the sentence and the number of occurrences.
Input
The input data contains multiple test instances, each of which is a line of English sentences with a length of not more than 100.
Output
Row by line outputs the most frequently occurring characters in each sentence and the number of occurrences (if there are multiple characters in the same number, only the characters with the lowest ASCII code are output).
Sample input
I am a Studenta good programming problemabcd ABCD ABCD ABCD
Sample output
A 2o 4 a 2
Hint Source
/*************************************************************************> File Name: Character Statistics 2.c> AUTHOR:TTOP5 > blog:www.ttop5.net> Mail: [email protected]> Created time:2014 December 13 Saturday 21:44 18 seconds ************************ /#include <stdio.h> #include <memory.h> #include < String.h>int Main () { int cont[125]; Char str[100]; int I,mark,max; while (gets (str)!=null) { memset (cont,0,sizeof (int) *125); for (i=0; I<strlen (str); i++) { if (str[i]!= ') cont[str[i]]++; } max=0; for (i=65; i<123; i++) { if (Max<cont[i]) { max=cont[i]; mark=i; } } printf ("%c%d\n", Mark,max); } return 0;}
Character Statistics 2