题目链接:FZU 2122 又见LKity
以为是KMP的,没想到暴力直接过了。。
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAX_N = 100 + 10;
const int MAX_M = 50000 + 100;
char s1[MAX_N], s2[MAX_N], s3[MAX_M];
int main()
{
while(gets(s1)&& strcmp(s1, ""))
{
gets(s2);
gets(s3);
int len1 = strlen(s1);
int len2 = strlen(s2);
int len3 = strlen(s3);
bool flag = true;
int k;
for(int i = 0; i < len3; i++)
{
k = i;
if(tolower(s3[i]) == tolower(s1[0]))
{
i++;
for(int j = 1; j < len1; j++)
{
if(tolower(s3[i]) != tolower(s1[j]))
{
i = k;
break;
}
else
i++;
if(j == len1 - 1)
i--;
}
}
if(k == i)
printf("%c", s3[i]);
else
{
for(int l = 0; l < len2; l++)
printf("%c", s2[l]);
}
}
puts("");
}
return 0;
}