| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么总是wa,哪个大牛能说说……#include<iostream>
#include<map>
#include<string>
using namespace std;
int n,m;
string namelist[10];
char step[]=" !";
void inputname()
{
int i;
for(i=1;i<=n;i++)
cin>>namelist[i];
}
void fun(char s[])
{
map<string,int> mp;
int word=0;
char* t;
t=strtok(s,step);
bool keyword=false;
while(t!=NULL)
{
word++;
if(t[0]>='A'&&t[0]<='Z') t[0]=t[0]-'A'+1;
if(!strcmp(t,"beautiful")||!strcmp(t,"pretty")||!strcmp(t,"lovely"))
keyword=true;
mp[(string)t]++;
t=strtok(NULL,step);
}
int i;
int b[10],k=0;
for(i=1;i<=n;i++)
{
if(mp[namelist[i]]>0) b[++k]=i;
}
if(k==0) cout<<"All: ";
else
{
for(i=1;i<k;i++)
cout<<namelist[b[i]]<<" ";
cout<<namelist[b[i]]<<": ";
}
if(word<=9) cout<<"oh"<<endl;
else
{
if(keyword)
{
cout<<"xixi"<<endl;
}
else
cout<<"hehe"<<endl;
}
mp.clear();
}
int main()
{
// freopen("pku_1677.in","r",stdin);
while(scanf("%d %d\n",&n,&m)!=EOF)
{
inputname();
getchar();
int i;
char s[1000];
for(i=1;i<=m;i++)
{
gets(s);
fun(s);
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator