2775: The argument of the alphabetTime limit:1 Sec Memory limit:128 MB
submit:84 solved:57
[Submit] [Status] [Web Board]
Description
One day, 26 lowercase English letters argued, they all want to be the boss, make a fuss. At this time the small armor of the tease think of a good way to calm them down, the rule is this: read a line consisting only of lowercase English letter string, statistics these 26 lowercase English letters in this string of characters appear in the number of times, who appeared this number of who is the eldest. In addition, the lowercase English letters that do not appear in this string of characters can only be beats me. Although this approach to some of the letters some unfair, but people still bite the bullet to accept. Well, now that the problem is coming, smart you can make up the procedure to help them solve it.
Input
A single string of lowercase English letters, with no other types of characters.
Output
Output the highest number of letters and times, and output ASCII large if the number of occurrences is the same
Sample Input
Goodgoodstudydaydayup
Sample Output
D:5
HINT
Source
Zhuang Liu &oj
AC Code:
#include <stdarg.h>
#include <iostream>
#include <math.h>
#include <iomanip>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;
int main () {
string s;
while (cin>>s) {
int len=s.length ();
int p[26],t[26],z;
memset (P,0,sizeof (P));
memset (t,0,sizeof (t));
for (int i=0;i<len;i++) {
if (Islower (S[i])) {
z=s[i]-96;
p[z]++;
}
}
int max=-111,oo=0;
for (int i=0;i<26;i++) {
if (P[i]>max) {
max=p[i];
oo=i;
}
}
Sort (p,p+26);
char c;
cout<< (c=oo+96+ ') << ":" <<p[25]<< ' \12 ';
}
return 0;
}