uva-10340-水题

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

直接循环

#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;
}

猜你喜欢

转载自www.cnblogs.com/shuiyonglewodezzzzz/p/9961260.html