您的位置:首页 > 其它

Uva - 10340 - All in All(指针扫描)

2013-07-31 15:02 260 查看
题意 :给出两个字符串s、t,问s是不是t的子串(不用连续)。

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=457&problem=1281

——>>一个个扫描……感觉这次写得挺。。。

#include <iostream>
#include <string>

using namespace std;

int main()
{
string s, t;
while(cin >> s >> t){
int len_s = s.length(), len_t = t.length(), i, j;
for(i = 0, j = 0; i < len_t; i++){
if(t[i] == s[j] && (++j) == len_s) break;
}
if(j == len_s) cout << "Yes" << endl;
else cout << "No" <<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: