您的位置:首页 > 其它

hdu 1251 统计难题 (map水过)

2015-12-31 17:37 363 查看
# include <stdio.h>
# include <algorithm>
# include <string>
# include <map>
# include <iostream>
using namespace std;
int main()
{
char a;
string  x;
map<string,int>q;
while(true)
{
scanf("%c",&a);
if(a=='\n')
{
scanf("%c",&a);
x="";//一个结束x初始化
}
if(a=='\n')//连续两个\n结束了母串的输入
break;
x+=a;
q[x]+=1;
}
while(cin>>x)
printf("%d\n",q[x]);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: