这道题目真的很水欸,还以为越来越难╮(╯▽╰)╭
题目
输入两个字符串s和t,判断是否可以从t中删除0个或者多个字符(其他字符顺序不变),得到字符串t。
样例输入
abcde bce
abcd bc
样例输出
no
yes
代码如下:(:з)∠)
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
using namespace std;
string s,t;
int main()
{
while(cin>>s>>t)
{
int l1,l2,counts=0;
l1=s.length();
l2=t.length();
for(int i=0;i<l1;i++)
{
if(s[i]==t[counts])
counts++;
}
if(counts==l2)//只需最后判断满足的与t字符串长度比较~
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}