Link:
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_ problem&problem=1281
Original title:
Have devised a new encryption technique which encodes a message by inserting between its characters randomly Strings in a clever way. Because of pending patent issues we won't discuss in detail how the strings are generated and inserted into the Origina L message. To validate your method, however, it's necessary to write a program that's checks if the message was really encoded in the F Inal string.
Given two strings s and T, you are have to decide whether s are a subsequence of T, i.e. if you can remove characters from T su Ch that 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. The Input is terminated by EOF.
Output specification
For each test case output, if s a subsequence of T.
Sample Input
Sequence subsequence
Person compression
VERDI Vivavittorioemanuelerediitalia
Casedoesmatter Casedoesmatter
Sample Output
Yes
No
Yes
No
Analysis and Summary:
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/
A simple question that directly determines whether a string is a substring of another string.
Code:
* * uva:10340-all in all
* time:0.008s
* author:d_double
/
#include < iostream>
#include <cstdio>
#include <cstring>
using namespace std;
Char str1[1000000], str2[1000000];
BOOL Judge () {
int pos=0, I;
for (i=0; I<strlen (str1); ++i) {
bool flag=false;
while (Pos < strlen (str2)) {
if (str2[pos]==str1[i)) break
;
++pos;
}
if (Pos==strlen (STR2)) return false;
++pos;
}
if (I==strlen (STR1)) return true;
return false;
}
int main () {
while (scanf ("%s%s", STR1,STR2)!=eof) {
if (judge ()) printf ("yes\n");
else printf ("no\n");
}
return 0;
}
Author: csdn Blog shuangde800