UVa 10340 All in All

提交时注意样例范围大于100000,WQNMLGB又没告诉,顺便扫描时比较j == strlen()的值,而不是j == strlen()-1,因为最后一位0也要比较

#include <iostream>
#include <cstring>
using namespace std;

char s[501000];
char t[501000];

int main()
{
	
	while(cin >> s >> t)
	{
		int j = 0;
		int strs = strlen(s);
		//cout << s[strlen(s)] << endl;
		int strt = strlen(t); 
		for(int i = 0; i < strt; i++)
		{
			if(t[i] == s[j] && j != strs)
			  j++; 
		}
		if(j == strs) cout << "Yes" << endl;
		else  cout << "No" << endl;
	}
	return 0;
}


你可能感兴趣的:(uva)