#include<cstdio>
#include<cstring>
int n, minlen = 256, cnt = 0;
char str[100][256];
int main(){
scanf("%d", &n);
getchar(); //接收换行符
for(int i = 0; i < n; i++){
fgets(str[i],256,stdin);
int len = strlen(str[i])-1;
if(len < minlen) minlen = len;
for(int j = 0; j < len/2; j++){
char temp = str[i][j];
str[i][j] = str[i][len-j-1];
str[i][len-j-1] = temp;
}
}
for(int i = 0; i < minlen; i++){
char ch = str[0][i];
bool same = true;
for(int j = 1; j < n; j++){
if(ch != str[j][i]){
same = false;
break;
}
}
if(same) cnt++;
else break;
}
if(cnt != 0){
for(int i = cnt - 1; i >= 0; i--){
printf("%c",str[0][i]);
}
}
else{
printf("nai");
}
return 0;
}
原文地址:https://www.cnblogs.com/zjsaipplp/p/10425239.html
时间: 2024-10-02 03:29:45