题意:给定两个字符串,问第一个串能不能从第二个串通过删除0个或多个字符得到。

析:那就一个字符一个字符的匹配,如果匹配上了就往后走,判断最后是不是等于长度即可。

代码如下:

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath> using namespace std;
string s1, s2; int main(){
while(cin >> s1 >> s2){
if(s1.size() > s2.size()){ cout << "No\n"; continue; } int j = 0;
for(int i = 0; i < s2.size(); ++i)
if(j == s1.size()) break;
else if(s2[i] == s1[j]) ++j; if(j == s1.size()) cout << "Yes\n";
else cout << "No\n";
}
}

UVa 10340 All in All (水题,匹配)的更多相关文章

  1. UVa 10340 - All in All 水题 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  2. UVa 11636 Hello World! (水题思维)

    题意:给你一个数,让你求需要复制粘贴多少次才能达到这个数. 析:这真是一个水题,相当水,很容易知道每次都翻倍,只要大于等于给定的数就ok了. 代码如下: #include <iostream&g ...

  3. UVA 10340 - All in All 水~

    看题传送门 Problem E All in All Input: standard input Output: standard output Time Limit: 2 seconds Memor ...

  4. uva 489 Hangman Judge(水题)

    题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&am ...

  5. uva 10252 - Common Permutation 字符串水题

    题意:給定兩個小寫的字串a與b,請印出皆出現在兩字串中的字母,出現的字母由a~z的順序印出,若同字母出現不只一次,請重複印出但不能超過任一字串中出現的次數.(from Ruby兔) 很水,直接比较输出 ...

  6. UVA 11947 Cancer or Scorpio 水题

    Cancer or Scorpio Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://uva.onlinejudge.org/index.php? ...

  7. UVA 11100 The Trip, 2007 水题一枚

    题目链接:UVA - 11100 题意描述:n个旅行箱,形状相同,尺寸不同,尺寸小的可以放在尺寸大的旅行箱里.现在要求露在最外面的旅行箱的数量最少的同时满足一个旅行箱里放的旅行箱的数量最少.求出这样满 ...

  8. UVA 11461 - Square Numbers 数学水题

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  9. uva 11059 maximum product(水题)——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB1QAAAMcCAIAAABo0QCJAAAgAElEQVR4nOydW7msuhKF2wIasIAHJK

  10. uva 10976 fractions again(水题)——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB3gAAAM+CAIAAAB31EfqAAAgAElEQVR4nOzdO7KtPJum69GEpAcVQQ ...

随机推荐

  1. springmvc initial初始化

    项目需求是在启动服务时,将某些内容放入到共同里面,例如数据字典表内容. 但数据字典表内容存在于数据库中,使用传统的listener在加载时,无法获取service实例,打开事务控制. springmv ...

  2. EL&jsp

    JSP 2.0(java server pages): EL 表达式 JSP九大内置对象及作用范围 JSP Directive JSP Action EL表达式: EL 算法(Arithmetic)表 ...

  3. vc 读xml文件 宏

    自定义FOREACH循环,便于coding 在指定xml的nodelist b中遍历每个节点 #define FOREACH_NODE(a,b)\ long cnt = 0; \ CComPtr< ...

  4. Ibatis/Mybatis模糊查询

    Ibatis/Mybatis模糊查询 根据网络内容整理 Ibatis中 使用$代替#.此种方法就是去掉了类型检查,使用字符串连接,不过可能会有sql注入风险. Sql代码 select * from ...

  5. delphi实现两个目录路径的链接

    filepath := PathJoin(['C:', 'path1', 'path2\', 'a.doc']); // filepath = 'C:\path1\path2\a.doc' 代码: f ...

  6. CSS3 弹性盒模型 box-flex

    说明:本文档兼容性测试基础环境为:windows系统:IE6-IE10, Firefox6.0, Chrome13.0, Safari5.1, Opera11.51 语法: box-flex:< ...

  7. jqeury datatable/http://www.cnblogs.com/jobs2/p/3431567.html

    0.http://blog.csdn.net/mickey_miki/article/details/8240477 1.1 修改默认值 代码  841处options 添加分页选择 oInit.bL ...

  8. Mysql 内部默认排序

    mysql默认的排序: https://forums.mysql.com/read.php?21,239471,239688#msg-239688 Do not depend on order whe ...

  9. The maximum column size is 767 bytes (Mysql)

     ERROR app.wsutils 419 INCRON: Error: ('HY000', '[HY000] [MySQL][ODBC 5.2(w) Driver][mysqld-5.7.7-rc ...

  10. form 表单排序

    <html>  <head></head>  <body>   <form class="form-inline">  ...