第5讲8
#include <iostream>
using namespace std;
const int N = 200;
int n;
string str[N];
int main()
{
int n;
while(cin >> n,n)
{
string str[210];
int i = 0;
int min = 1000;
while(i < n)
{
cin >> str[i];
if(str[i].size() < min) min = str[i].size();
i++;
}
for (int i = 1; i <= min; i++)//枚举后缀长度
{
int flag = 1;
for (int j = 0; j < n; j++)//枚举n个字符串
{
int len0 = str[0].size();
int len = str[j].size();
if (str[0].substr(len0-i) != str[j].substr(len-i))
{
cout << str[0].substr(len0-i+1) << endl;
flag = 0;
break;
}
}
if (!flag) break;
if(i == min) cout << str[0].substr(str[0].size()-min, min) << endl;
}
}
return 0;
}