| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WHY WRONG?#include <iostream>
#include<string.h>
using namespace std;
int main()
{
int m;
cin>>m;
char str1[100],str2[100];
int len1,len2,i,j;
while(m--)
{
cin>>str1>>str2;
j=0;
len1 = strlen(str1);
len2 = strlen(str2);
for(i = 0 ; i < len1 ; i ++)
{
if( str1[i] == str2[j])
{
j++;
}
else continue;
}
//cout<<"j=="<<j<<endl;
if(j == len2)
cout<<"Yes\n";
else
{
j=0;
_strrev(str1);
// cout<<"str1 "<<str1<<endl;
for(i = 0;i <len1;i ++)
{
if( str1[i] == str2[j])
{
j++;
}
else continue;
}
//cout<<"j==="<<j<<endl;
if(j == len2)
cout<<"Yes"<<endl;
else cout<<"NO"<<endl;
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator