| ||||||||||
| 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 | |||||||||
Re:字符串老WA,放弃它了In Reply To:字符串老WA,放弃它了 Posted by:OSJake at 2009-06-10 15:24:43 #include<iostream>
#include<string>
using namespace std;
int f(char a[],char b[])
{
int lea=strlen(a),leb=strlen(b),i,j=0;
for(i=0;i<lea;i++) if(a[i]==b[j]) j++;
if(j==leb) return 1;
else return 0;
}
int g(char a[],char b[])
{
int lea=strlen(a),i,j=strlen(b)-1;
for(i=0;i<lea;i++) if(a[i]==b[j]) j--;
if(j==-1) return 1;
else return 0;
}
int main()
{
int x;
scanf("%d",&x);
while(x--){
char a[200],b[200];
cin>>a>>b;
if(f(a,b)==0&&g(a,b)==0) cout<<"NO"<<endl;
else cout<<"YES"<<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