//自己不会写 但是看懂了学长写的
#include <iostream>
#include <string> //string类
#include <map>
using namespace std;
int main()
{
map<string,bool>hash;//hash散列 我发现把hash改成别的也对
string str[150000];
hash.clear(); //清空hash
string temp;
string a,b;
int num=0;
while(cin>>str[num]) //输入str
{
hash[str[num]]=true;
num++;
}
// num 输入的单词个数
for(int i=0;i<num;i++)
{
temp=str[i]; //temp 为第一个 第二个 第三个 ......单词
for(int j=0;j<temp.size()-1;j++)//加1 是为了防止越界
{
a=temp.substr(0,j+1); //a 是第一个 第二个 第三个 ......单词从第一个字母到第j+1个字母
b=temp.substr(j+1); //b 是第一个 第二个 第三个 ......单词从第j+1个字母直到最后
if(hash[a]&&hash[b]) //如果 输入的单词中有 a 又有 b
{
cout<<temp<<endl; //那么输出temp
break;
}
}
}
return 0; //hahaha ok啦
}
#include <iostream>
#include <string> //string类
#include <map>
using namespace std;
int main()
{
map<string,bool>hash;//hash散列 我发现把hash改成别的也对
string str[150000];
hash.clear(); //清空hash
string temp;
string a,b;
int num=0;
while(cin>>str[num]) //输入str
{
hash[str[num]]=true;
num++;
}
// num 输入的单词个数
for(int i=0;i<num;i++)
{
temp=str[i]; //temp 为第一个 第二个 第三个 ......单词
for(int j=0;j<temp.size()-1;j++)//加1 是为了防止越界
{
a=temp.substr(0,j+1); //a 是第一个 第二个 第三个 ......单词从第一个字母到第j+1个字母
b=temp.substr(j+1); //b 是第一个 第二个 第三个 ......单词从第j+1个字母直到最后
if(hash[a]&&hash[b]) //如果 输入的单词中有 a 又有 b
{
cout<<temp<<endl; //那么输出temp
break;
}
}
}
return 0; //hahaha ok啦
}