菜菜

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

题意:字符串匹配,看样例输入理解题意

 

直接循环

#include <string>
#include<iostream>
#include<map>
#include<memory.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<math.h>
#include<iomanip>


namespace cc
{
    using std::cout;
    using std::endl;
    using std::cin;
    using std::map;
    using std::vector;
    using std::string;
    using std::sort;
    using std::priority_queue;
    using std::greater;
    using std::vector;
    using std::swap;
    using std::stack;


    constexpr double MD = 1e-6;


    

    void solve()
    {
        string str1, str2;
        while (cin>>str1>>str2) 
        {
            int ok = 0;
            for (int i=0;i<str2.length();i++) 
            {
                if (str2[i] == str1[0])
                {
                    int k =  1;
                    for (int j=i+1;j<str2.length()&&k<str1.length();j++) 
                    {
                        if (str2[j] == str1[k])
                            ++k;
                    }
                    if (k == str1.length())
                    {
                        ok = 1;
                        break;
                    }
                }
            }
            if (ok)
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
        }

    }

};


int main()
{

#ifndef ONLINE_JUDGE
    freopen("d://1.text", "r", stdin);
#endif // !ONLINE_JUDGE
    cc::solve();

    return 0;
}

 

posted on 2018-11-15 00:21  好吧,就是菜菜  阅读(106)  评论(0编辑  收藏  举报