i從t開始搜,
搜到與s[j]一樣就讓j++,
這樣到最後如果j與s字串的長度一樣,
即表示答案是Yes,
反之則是No。
[C](0.012)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<string.h> | |
int main() | |
{ | |
char s[100000] = {0}, t[100000] = {0}; | |
while( scanf( "%s%s", s, t ) != EOF ) | |
{ | |
int slength = strlen(s); | |
int tlength = strlen(t); | |
int i, j; | |
for( i = 0, j = 0 ; i < tlength && j < slength ; i++ ) | |
if( t[i] == s[j] ) | |
j++; | |
if( j == slength ) | |
printf( "Yes\n" ); | |
else | |
printf( "No\n" ); | |
} | |
return 0; | |
} |
0 意見:
張貼留言