题意:判断字符串s是否是t的字串。

题解:从头开始一一比对,最后正确数量是s的长度是yes,否则no。

#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace std;

string str1, str2;

int main() {
	while (cin >> str1 >> str2) {
		int len1 = str1.size();
		int len2 = str2.size();
		int temp = 0, pos = 0;
		for (int i = 0; i < len1; i++)
			for (int j = pos; j < len2; j++) {
				if (str2[j] == str1[i]) {
					temp++;
					pos = j + 1;
					break;
				}
			}
		if (temp == len1)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}