uva10340

Problem E

All in All

Input: standard input

Output: standard output

Time Limit: 2 seconds

Memory Limit: 32 MB

You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are generated and inserted into the original message. To validate your method, however, it is necessary to write a program that checks if the message is really encoded in the final string.

Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s.

Input Specification

The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace. Input is terminated by EOF.

Output Specification

For each test case output, if s is a subsequence of t.

Sample Input

sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter

Sample Output

Yes
No
Yes
No
题目大意:判断字符数组是不是另一个的子串(删除n个字符,n可以等于0)
分析:水题
 1 #include<iostream>
 2 #include<cstring>
 3 #include<cstdlib>
 4 #include<cstdio>
 5 #include<cmath>
 6 #include<string>
 7 using namespace std;
 8 string a,b;
 9 int main()
10 {
11     while(cin>>a>>b)
12     {
13         int flag=0,lena=a.size(),lenb=b.size();
14         for(int i=0; i<lenb; i++)
15         {
16             if(flag==lena)
17                 break;
18             else  if(a[flag]==b[i])
19                 flag++;
20         }
21         if(flag==lena)
22             cout<<"Yes"<<endl;
23         else
24             cout<<"No"<<endl;
25     }
26     return 0;
27 }
View Code
原文地址:https://www.cnblogs.com/shuzy/p/3188291.html