zoukankan      html  css  js  c++  java
  • 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
    屌丝终有逆袭日,*******。
  • 相关阅读:
    JQuery中的id选择器含有特殊字符时,不能选中dom元素
    解决Mac下MySQL登录问题
    Mac 安装mysql
    禁止chrome浏览器自动填充表单的解决方案
    Eclipse 编译错误 Access restriction: The type 'JPEGCodec' is not API (restriction on required library 'C:Program FilesJavajre7lib t.jar')
    羊皮纸月亮计划
    ActionSupport.getText()方法
    linux入门经验之谈
    tomcat设置默认启动项
    网页设置下载apk
  • 原文地址:https://www.cnblogs.com/ZhaoPengkinghold/p/3856018.html
Copyright © 2011-2022 走看看