#include <cstdio>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <ctype.h>
using namespace std;
map<string , int> result ;
bool isLetter(char c)
{
if( '0' <= c && c <= '9' || 'a' <= c && c<= 'z' || 'A' <= c && c <= 'Z' )
{
return true;
}
return false ;
}
int main(void)
{
string data;
int i = 0;
int s , e ;
int max = 0 ;
vector<int>value ;
map<string , int> ::iterator it ;
//freopen("input.txt" , "r" , stdin);
getline(cin , data);
while( i < data.length() )
{
string temp ;
while( i < data.length() && !isLetter( data.at(i) ))
{
i++ ;
}
if( i == data.length() ) break ;
s = i ;
while( i < data.length() && isLetter( data.at(i) ))
{
data.replace( i , 1 , 1 , tolower( data.at(i) ) ) ;
i++ ;
}
e = i;
temp = data.substr( s , e - s );
//´æ´¢Ïà¹ØµÄ×Ö·û´®
if( result.count( temp ) == 0 )
{
result[temp] = 1 ;
}
else
{
result[temp] ++ ;
}
if( result[temp] > max )
{
max = result[temp] ;
}
}
for( it = result.begin() ; it != result.end() ; it++ )
{
if( it->second == max)
{
cout<<it->first << ' ' << it->second << endl;
}
}
return 0;
}
1071. Speech Patterns
最新推荐文章于 2020-08-23 13:56:07 发布