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

WHY WRONG?

Posted by 980616701 at 2009-06-02 12:44:11 on Problem 3302
#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:
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