FZU 2122 又见LKity

直接模拟或者KMP

 1 #include <iostream>
 2 #include <string.h>
 3 #include <stdio.h>
 4 #include <algorithm>
 5 #include <cmath>
 6 #include <cstdlib>
 7 using namespace std;
 8 const double pi=acos(-1);
 9 const int maxn=200010;
10 char s1[maxn],s2[maxn],s[maxn],c[maxn];
11 int main() {
12     // freopen("in.txt","r",stdin);
13     while(gets(s1)) {
14         int len1=strlen(s1);
15         for(int i=0; i<len1; i++) {
16             if(s1[i]>='A'&&s1[i]<='Z')
17                 s1[i]+=32;
18         }
19         gets(s2);
20         int len2=strlen(s2);
21         gets(s);
22         int len=strlen(s),flag,flag1,k=0;
23         for(int i=0; i<len; i++) {
24             flag1=1;
25             if(s[i]==s1[0]||s[i]==s1[0]-32) {
26                 int ii=i+1;
27                 flag=0,flag1=0;
28                 for(int j=1; j<len1; j++,ii++) {
29                     if(s[ii]!=s1[j]&&s[ii]!=s1[j]-32) {
30                         flag=1;
31                         break;
32                     }
33                 }
34             }
35             if(!flag&&!flag1) {
36                 for(int j=0; j<len2; j++) {
37                     c[k++]=s2[j];
38                 }
39                 i+=len1-1;
40             }
41             else {
42                 c[k++]=s[i];
43             }
44         }
45         for(int i=0; i<k; i++) {
46             printf("%c",c[i]);
47         }
48         printf("\n");
49     }
50     return 0;
51 }
View Code

 

posted @ 2016-03-30 21:45  yyblues  阅读(203)  评论(0编辑  收藏  举报