判断s串中的字符是不是依次出现在t串中,如果s的长度大于t,显然不行,其他的依次比较即可。
但是字符串要定义得长一些,开始定义10000,RE了。
#include<stdio.h>
#include<string.h>
char s[100000], t[100000];
int main()
{
while( scanf( "%s%s", s, t) == 2)
{
int len1 = strlen(s);
int len2 = strlen(t);
if( len1 > len2) {
printf( "No\n");
continue;
}
int i, j;
for( i = 0, j = 0; j < len2; j ++)
{
if( s[i] == t[j]) i ++;
if( len1 - i > len2 - j) break;
}
if( i == len1) printf( "Yes\n");
else printf( "No\n");
}
return 0;
}
浙公网安备 33010602011771号