题目描述
又见LKity
解题思路
参考代码
#include <stdio.h>
#include <string.h>
#include <ctype.h>
const int maxn = 50050;
char str[maxn],s1[150],s2[150],temp[150];
bool judge(char* s1,char* s2,int len){
int i;
for (i = 0;i < len;i++){
if (!isalpha(s1[i]))
return false;
if (tolower(s1[i]) != tolower(s2[i]))
return false;
}
return true;
}
int main()
{
while (gets(s1)){
gets(s2);
gets(str);
int i,len = strlen(str),n = strlen(s1);
char *p = str;
for (i = 0;i < len;i++){
if (*(p+n)){
strncpy(temp,p,n);
if (judge(temp,s1,n)){
printf("%s",s2);
p += n;
i += n-1;
}else{
putchar(str[i]);
p++;
}
}else{
printf("%s",(judge(p,s1,n))?s2:p);
break;
}
}
printf("\n");
}
return 0;
}