poj1936(All in All)

题目地址:All in All

题目大意: 

    判断后一个字符串是否包含前一个字符串,顺序不能改变。

解题思路:

    以后一个字符串为循环,与要判断的字符串中的字符相等就cnt++。最后cnt==len(需要判断的字符串)是输出YES否则NO。

代码:

 1 #include <algorithm>
 2 #include <iostream>
 3 #include <sstream>
 4 #include <cstdlib>
 5 #include <cstring>
 6 #include <cstdio>
 7 #include <string>
 8 #include <bitset>
 9 #include <vector>
10 #include <queue>
11 #include <stack>
12 #include <cmath>
13 #include <list>
14 //#include <map>
15 #include <set>
16 using namespace std;
17 /***************************************/
18 #define ll long long
19 #define int64 __int64
20 /***************************************/
21 const int INF = 0x7f7f7f7f;
22 const double eps = 1e-8;
23 const double PIE=acos(-1.0);
24 const int d1x[]= {-1,1,0,0};
25 const int d1y[]= {0,0,-1,1};
26 const int d2x[]= {0,-1,0,1};
27 const int d2y[]= {1,0,-1,0};
28 const int fx[]= {-1,-1,-1,0,0,1,1,1};
29 const int fy[]= {-1,0,1,-1,1,-1,0,1};
30 /***************************************/
31 void openfile()
32 {
33     freopen("data.in","rb",stdin);
34     freopen("data.out","wb",stdout);
35 }
36 /**********************华丽丽的分割线,以上为模板部分*****************/
37 char s1[100001],s[100001];
38 int main()
39 {
40     while(scanf("%s",s1)!=EOF)
41     {
42         scanf("%s",s);
43         int i,j;
44         int len1=strlen(s1);
45         int len2=strlen(s);
46         int d=0;
47         int cnt=0;
48         for(i=0; i<len2; i++)
49         {
50             if (s[i]!=s1[d])
51                 continue;
52             if (s[i]==s1[d])
53             {
54                 cnt++;
55                 d++;
56             }
57 
58         }
59         if (cnt==len1)
60                 printf("Yes
");
61             else
62                 printf("No
");
63     }
64     return 0;
65 }
View Code
屌丝终有逆袭日,*******。
原文地址:https://www.cnblogs.com/ZhaoPengkinghold/p/3856018.html