解题报告.ppt

解题报告.ppt

解 题 报 告 @计2 郑扬涛 题目大意: 给定两个字符串s和t. 问能否在s中找到一子序列s’,与t相同. 子序列:从最初序列通过去除某些元素但不破坏余下元素的相对位置(在前或在后)而形成的新序列 子串:任意个连续的元素组成的子序列 记 得 存 档 思路分析 对于t中每个元素t[i],按顺序查找是否有s[j] == t[i].若相等的次数等于t中元素的个数,则说明存在s’ #include?stdio.h?? #include?string.h?? const?int?maxn?=?100010;?? char?t[maxn],s[maxn];?? bool?find?();?? int?main()?? {?? ????while?(scanf(“%s?%s”,t,s) != EOF)?? ????????printf(%s\n,find()?Yes:No);?? ????return?0;?? }?? bool?find?(){?? ????int?len1?=?strlen(t),len2?=?strlen(s);?? ????int?cnt?=?0,pos?=?0;?? ????int?i,j;?? ????for?(i?=?0;i??len1;i++){?? ????????for?(j?=?pos;j??len2;j++)?? ????????????i

文档评论(0)

1亿VIP精品文档

相关文档