首页 > 代码库 > uva 10340 all in all

uva 10340 all in all

#include<bits/stdc++.h>
using namespace std;
bool cmpare(string t,string s)
{
    int t_size=t.size();
    int s_size=s.size();
    int t_ipos=0,s_ipos=0;
    while(t_ipos<t_size&&s_ipos<s_size)
    {
        if(t[t_ipos]==s[s_ipos])
        {
            t_ipos++;
            s_ipos++;
        }
        else
            s_ipos++;
    }
    if(s_ipos==s_size&&t_ipos!=t_size)
        return false;
    return true;
}
int main()
{
    string a,b;
    while(cin>>a>>b)
    {
        if(cmpare(a,b))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}

  就一句话,直接模拟,往后移动下标就行。

uva 10340 all in all