Problem Description
You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.
Input
The first line of the input file contains a single integer t (1 <= t <= 10), the number of test cases, followed by the input data for each test case. The first line of each test case contains a single integer n (1 <= n <= 100), the number of given strings, followed by n lines, each representing one string of minimum length 1 and maximum length 100. There is no extra white space before and after a string.
Output
There should be one line per test case containing the length of the largest string found.
Sample Input
2
3
ABCD
BCDFF
BRCD
2
rose
orchid
Sample Output
2
2
1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <windows.h> 5 void sort(char (*str)[101]); //给字符串序列按长度排序 6 int fun(char (*str)[101]); //求发现的最大的子串的长度 7 //char* in_turn(char* s); //字符串逆序 8 9 int main() 10 { 11 int t,n; 12 scanf("%d",&t); 13 while(t--) //提前判断范围 14 { 15 int i=0; 16 char str[100][101]={0}; 17 scanf("%d",&n); 18 while(i<n) 19 { 20 scanf("%s",str[i++]); //gets会接收一个换行符 21 } 22 sort(str); 23 printf("%d ",fun(str)); 24 } 25 system("pause>nul"); 26 return 0; 27 } 28 29 int fun(char (*str)[101]) 30 { 31 int max=0,i,j,k; 32 char s[101]; 33 for(k=0;str[0][k];k++) 34 { 35 for(i=1;i<=strlen(str[0])-k;i++) 36 { 37 if(max>i) continue; 38 int flag=1; 39 strcpy(s,str[0]+k);//i-k+1 40 s[i]='