Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:字符串老WA,放弃它了

Posted by qylsw at 2010-07-18 13:25:53 on Problem 3302
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator