#include<iostream>
#include<string>
using namespace std;
int main()
{
int N,len1,len2,i,j;
char st1[101],st2[101];
cin>>N;
while(N--)
{
cin>>st1>>st2;
bool key=false;
int number1=0;
len1=strlen(st1);
len2=strlen(st2);
i=j=0;
while(i<len1&&j<len2)
{
if(st1[i]==st2[j])
{
i++;j++;
number1++;
}
else
i++;
}
if(number1==len2)
key=true;
i=0;j=len2-1;
number1=0;
while(i<len1&&j>=0)
{
if(st1[i]==st2[j])
{
i++;j--;
number1++;
}
else
i++;
}
if(number1==len2)
key=true;
if(key)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
<iostream>
#include<string>
using namespace std;
int main()
{
int N,len1,len2,i,j;
char st1[101],st2[101];
cin>>N;
while(N--)
{
cin>>st1>>st2;
bool key=false;
int number1=0;
len1=strlen(st1);
len2=strlen(st2);
i=j=0;
while(i<len1&&j<len2)
{
if(st1[i]==st2[j])
{
i++;j++;
number1++;
}
else
i++;
}
if(number1==len2)
key=true;
i=0;j=len2-1;
number1=0;
while(i<len1&&j>=0)
{
if(st1[i]==st2[j])
{
i++;j--;
number1++;
}
else
i++;
}
if(number1==len2)
key=true;
if(key)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
北大OJ3302
最新推荐文章于 2021-11-03 23:14:49 发布