处理第一行 fi , 从len = 60 到 3 ,起点从i =0 ...m-1 枚举所有子串,跟1...n-1 行去比较;
函数 strncpy (目的存储地址,被复制的起始地址,长度) ; 最好手动加 目的数组【len】= '\0'
strcmp(s1,s2) : ==1 代表s1 字典序大于 s2 ;
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<map>
#include<set>
using namespace std;
const int m=60;
char fi[m+10];
char str[13][m+10];
int n;
char ans[m+10],tp[m+10];
int la;
//bool OK(int r,int j){
// int st=0;
// while(tp[st]){
// if(tp[st]!=str[r][j])
// return 0;
// else
// st++,j++;
// }
// return 1;
//}
//bool check(){
//
// for(int r=1;r<n;r++){
// bool f1=1,f2=1;
// for(int j=0;j<m;j++){
// if(str[r][j]==tp[0]){
// f1=0;
// if(OK(r,j)){
// f2=0;
// break;
// }
// }
// }
// if(f1 || f2) return 0;
// }
// return 1;
//}
bool check(){
for(int r=1;r<n;r++){
bool f=1;
for(int j=0;j<m;j++){
if(strstr(str[r]+j,tp)) f=0;
}
if(f) return 0;
}
return 1;
}
void deal(){
la=0;
ans[0]=0;
for(int len=m;len>2;len--){
for(int i=0;i<=m-len;i++){
strncpy(tp,fi+i,len);
tp[len]=0;
if(check()){
if(la==0) {
strcpy(ans,tp);
la=len;
}
else if(strcmp(ans,tp)>0) strcpy(ans,tp);
}
}
if(la) return ;
}
}
int main()
{
// freopen("in.in","r",stdin);
int T;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
scanf("%s",fi);
for(int i=1;i<n;i++)
scanf("%s",str[i]);
deal();
if(la<3) printf("no significant commonalities\n");
else printf("%s\n",ans);
}
return 0;
}