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

uva 10340 All in All

时间:2016-12-11 18:30:51      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:out   输入   char   str   iostream   using   turn   其他   include   

水题,从头到尾扫一遍就可以了,输入两个字符串s和t,判断是否可以从t中删除0个或多个字符(其他字符顺序不变),得到字符串s。例如,abcde可以得到bce,但无法得到dc。

#include<algorithm>  
#include<cstring>  
#include<cstdio> 
#include<iostream>
#define len  101000  

using namespace std;

char s[len], t[len];

int main()
{
    int sn, tn, ls, lt;
    while (cin >> s) {
        cin >> t;
        ls = strlen(s);
        lt = strlen(t);
        sn = 0;tn = 0;
        for (int i = 0;i < ls, i < lt;i++) {
            if (s[sn] == t[tn]) {
                sn++;
                tn++;
            }
            else {
                tn++;
            }
        }
        if (sn == ls)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

 

uva 10340 All in All

标签:out   输入   char   str   iostream   using   turn   其他   include   

原文地址:http://www.cnblogs.com/ArvinShaffer/p/6159781.html

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