码迷,mamicode.com
首页 > 其他好文 > 详细

FZU 2122 又见LKity

时间:2016-03-30 22:12:56      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

直接模拟或者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

 

FZU 2122 又见LKity

标签:

原文地址:http://www.cnblogs.com/ITUPC/p/5339070.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!