UVa 10340 All in all
題意:
輸入一個 目標字串A 和一個 字串B
求是否可以透過刪除 B 中的字元來得到 A
解題:
很簡單,按照目標字串的順序來搜尋就好了
這邊運用了字串結尾是虛字元'\0'(ACSII碼=0)
及c/c++ 0=false的規定
這邊運用了字串結尾是虛字元'\0'(ACSII碼=0)
及c/c++ 0=false的規定
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
//UVa 10340 All in all | |
#include <cstdio> | |
#include <cstring> | |
char sub[100000], str[100000]; | |
int main() { | |
while(scanf("%s%s", sub, str) == 2) { | |
int j = 0; | |
for (int i = 0; str[i]; ++i) { | |
if(str[i] == sub[j]) j++; | |
} | |
printf("%s\n", sub[j] ? "Yes" : "No"); | |
} | |
return 0; | |
} |
沒有留言:
張貼留言