这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
水题,不多说。
题目地址:
http://poj.grids.cn/problem/2742
// Grid 2742
// Author: Tanky Woo
#include
using namespace std;
char arr[1001];
int nCases;
int hash[26] = {0};
// www.wutianqi.com
int main()
{
scanf("%d", &nCases;);
while(nCases--)
{
memset(hash, 0, sizeof(hash));
getchar();
scanf("%s", arr);
for(int i = 0; i < strlen(arr); ++i)
hash[arr[i]-'a']++;
int id = 0;
for(int i = 0; i < 25; ++i)
if(hash[i] > hash[id])
id = i;
printf("%c %d\n", 'a'+id, hash[id]);
if(nCases == 0)
printf("\n");
}
return 0;
}