题目描述:算法竞赛入门经典习题3-9

题目思路:循环匹配

//没有按照原题的输入输出

#include <stdio.h>
#include <string.h>
#define maxn 100
int main(int argc, char *argv[])
{
char s[maxn],t[maxn] ;
scanf("%s%s",s,t) ;
int tlen = strlen(t) ;
int slen = strlen(s);
int k = ,j=;
for(int i=;i<tlen;i++){ while(j<slen){
if(t[i] == s[j]){
k++ ;
j++ ;
break ;
}
j++ ;
}
}
if(k == tlen) printf("YES\n") ;
return ;
}

子序列 (All in All,UVa10340)的更多相关文章

  1. UVA10340子序列

    题意:       给你两个串,问你第二个第一个串是否是第一个串删除0个或多个字母得到的? 思路:       直接模拟就行了,在第二个串中去按顺序更新第一个串的下标,好像没说明白啊,不管了,水题,不 ...

  2. 用python实现最长公共子序列算法(找到所有最长公共子串)

    软件安全的一个小实验,正好复习一下LCS的写法. 实现LCS的算法和算法导论上的方式基本一致,都是先建好两个表,一个存储在(i,j)处当前最长公共子序列长度,另一个存储在(i,j)处的回溯方向. 相对 ...

  3. codevs 1576 最长上升子序列的线段树优化

    题目:codevs 1576 最长严格上升子序列 链接:http://codevs.cn/problem/1576/ 优化的地方是 1到i-1 中最大的 f[j]值,并且A[j]<A[i] .根 ...

  4. [LeetCode] Arithmetic Slices II - Subsequence 算数切片之二 - 子序列

    A sequence of numbers is called arithmetic if it consists of at least three elements and if the diff ...

  5. [LeetCode] Is Subsequence 是子序列

    Given a string s and a string t, check if s is subsequence of t. You may assume that there is only l ...

  6. [LeetCode] Wiggle Subsequence 摆动子序列

    A sequence of numbers is called a wiggle sequence if the differences between successive numbers stri ...

  7. [LeetCode] Increasing Triplet Subsequence 递增的三元子序列

    Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the ar ...

  8. [LeetCode] Distinct Subsequences 不同的子序列

    Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

  9. 动态规划之最长公共子序列(LCS)

    转自:http://segmentfault.com/blog/exploring/ LCS 问题描述 定义: 一个数列 S,如果分别是两个或多个已知数列的子序列,且是所有符合此条件序列中最长的,则 ...

随机推荐

  1. Mysql 基本语句 + 高级查询

    MySQL执行SQL脚本文件的命令: 从cmd进入mysql命令行模式: mysql> -uroot –prootpassword –Ddatabasename 如果是我本地的数据库,就相应修改 ...

  2. Swift_属性

    Swift_属性 点击查看源码 class DataImporter { var fileName = "data.txt" init() { print("初始化&qu ...

  3. c++string标准输入和getline()整行读入

    1.使用标准IO操作读写string对象 我们都知道,使用标准iostream操作来读写int ,double等内置类型的值,同样,我们也可以使用IO操作来读写string对象. c++ code: ...

  4. MySQL数据导入导出(一)

    今天遇到一个需求,要用自动任务将一张表的数据导入另一张表.具体场景及限制:将数据库A中表A的数据导入到数据库B的表B中(增量数据或全量数据两种方式):体系1和体系2只能分别访问数据库A和数据库B.附图 ...

  5. 对于gitHub的总结随笔

    作用:用于项目的版本管理     密切相关的是       git                操作  1.本地的文件上传到github上                              ...

  6. Redis(三):Redis数据类型

    Redis数据类型目录导航: Redis五大数据类型 哪里去获取Redis常见数据类型操作命令 Redis键(Key) Redis字符串(String) Redis列表(List) Redis集合(S ...

  7. 「PHP」观察者模式模式

    引言   所属:行为型模式,常用设计模式之一       学习资料: <大话设计模式>程杰 模式概述   观察者模式定义了一种一对多的依赖关系,让多个观察者对象监听某一个主题对象.这个主题 ...

  8. EFI分区删除的有效方法

    用Diskpart命令,可以方便的删除EFI系统分区. 一,win + R, 输入cmd,回车. 二,输入 Diskpart ,回车,得到 三,再输入 list disk , 回车,查看磁盘信息 四, ...

  9. LCD驱动程序

    学习目标:熟悉TFT LCD的概念,分层驱动工作原理和程序编写. 一.LCD 概念 1.  显示器数据组织格式 1)一幅图像成为一帧,每帧由多行组成,每行由多个像素组成.每个像素的颜色由若干位表示,对 ...

  10. Linux3.5—IIC学习分析

    I2C控制器的设备对象内核已经实现并关联到platform总线. I2C控制器的驱动对象内核已经实现. 看mach-tiny4412.h /plat-samsung/目录下 /drivers/i2c/ ...