题目描述
blablabla
样例
blablabla
C++ 代码
#include<cstdio>
#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;
int n=0,mins=0;
vector<string> vec;
void fun(string &s){
string last;
for (int i = 1; i <= mins; ++i) {
string tmp=vec.at(0).substr(vec.at(0).length()-i,vec.at(0).length());;
for (int j = 1; j < vec.size(); ++j) {
string tmp1=vec.at(j).substr(vec.at(j).length()-i,vec.at(j).length());
if(tmp!=tmp1)
{
i==1?s="":s=last;
return;
}
}
last=tmp;
}
s=last;
}
int main(){
while(cin>>n&&n!=0){
vec.clear();
mins=0x3f3f3f;
for (int i = 0; i < n; ++i) {
string str;
cin>>str;
mins=min(mins,(int)str.length());
vec.push_back(str);
}
string s;
fun(s);
cout<<s<<endl;
}
return 0;
}