BNU Online Judge-34776-What does the fox say?
题目链接
http://www.bnuoj.com/bnuoj/problem_show.php?pid=34776
题意: fox 的叫声
例如测试用例
输入
toot woof wa ow ow ow pa blub blub pa toot pa blub pa pa ow pow toot
dog goes woof
fish goes blub
elephant goes toot
seal goes ow
what does the fox say?
输出
wa pa pa pa pa pa pow
这样理解就是其他动物没有叫过的声音就是fox叫的例如把toot woof wa ow ow ow pa blub blub pa toot pa blub pa pa ow pow toot 中woof blub toot ow
去掉就是答案。
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
map<string,int>M;
int main()
{
int t;
scanf("%d",&t);
char s1[11000];
char ss[150];
char sss[110][110];
map<char,int>::iterator it;
while(t--)
{
getchar();
gets(s1);
int k=0;
M.clear();
memset(sss,'\0',sizeof(sss));
while(scanf("%s",ss)&&strcmp(ss,"say?")!=0)
{
k++;
if(k%3==0)
{
M[ss]=1;
}
}
//it=M.end();
//printf("%d\n",M.size());
//it=M.find("the");
M.erase(M.end(),M.end());
int len=strlen(s1);
int ans=0;
for(int i=0; i<len; i++)
{
if(s1[i]==' ')
{
ans++;
continue;
}
char d[10];
d[0]=s1[i];
d[1]='\0';
strcat(sss[ans],d);
}
int flag=0;
for(int i=0; i<=ans; i++)
{
if(!M[sss[i]])
{
if(flag==0)
{
printf("%s",sss[i]);
flag++;
}
else
printf(" %s",sss[i]);
}
}
printf("\n");
}
return 0;
}