int func(char* query, char* text)
{
if (query == NULL || text == NULL)
return 0;
int len1 = strlen(query);
int len2 = strlen(text);
int sum = 0;
int count = 0;
for (int start = 0; start < len2; start++)
{
int i = start;
int j = 0;
count = 0;
while (i < len2 && j < len1)
{
if (query[j] == text[i])
{
i++;
j++;
count++;
}
else
{
if (sum < count)
sum = count;
i = start;
count = 0;
j++;
}
}
if (sum < count)
sum = count;
}
return sum;
}
int main(void)
{
char query[20];
char text[100];
scanf("%s",query);
scanf("%s",text);
int res = func(query, text);
printf("%d\n",res);
return 0;
}
2459

被折叠的 条评论
为什么被折叠?



