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

uva-10340-水题

时间:2018-11-15 01:34:58      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:循环   map   namespace   ace   while   expr   turn   ++   memory   

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

 

直接循环

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

 

uva-10340-水题

标签:循环   map   namespace   ace   while   expr   turn   ++   memory   

原文地址:https://www.cnblogs.com/shuiyonglewodezzzzz/p/9961260.html

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