UVa 10340 - All in All 水题 难度: 0
作者:互联网
题目
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1281
题意
问字符串a能否是字符串b的子序列
思路
明显,计数对的上就行
感想
因为忘了break错了一次
代码
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #define LOCAL_DEBUG using namespace std; typedef pair<int, int> MyPair; int main() { #ifdef LOCAL_DEBUG freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\input.txt", "r", stdin); //freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\output.txt", "w", stdout); #endif // LOCAL_DEBUG int T; string a, b; for (int ti = 1;cin>>a>>b; ti++) { int sza = 0, szb = 0; for (sza = 0, szb = 0; sza < a.size() && szb < b.size(); sza++, szb++) { while (szb < b.size() && a[sza] != b[szb]) { szb++; } if (szb >= b.size())break; } if (sza == a.size())puts("Yes"); else puts("No"); } return 0; }View Code
标签:include,水题,szb,sza,ACM,int,UVa,10340,size 来源: https://www.cnblogs.com/xuesu/p/10463059.html