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

Latest! 大侠帮帮忙,怎么wa了呢?

Posted by emperorlu at 2007-08-27 22:41:08 on Problem 3302
#include<stdio.h>
#include<string.h>
int f(char a[],char b[])
{
   int i,j,temp,flag;
   for(i=0,temp=0,flag=0;i<strlen(b);i++)
  {
     for(j=temp;j<strlen(a);j++)
    {
	 if(a[j]==b[i])
	 {
	    temp=j+1;
             break;
	 }
    }
     if(j==strlen(a))
    {
 	flag=1;
 	 break;
    }
  }
  return flag;
}
int main()
{
    int i,j,n,flag1,flag2;
    char a[100],b[100],c[100];
    scanf("%d",&n);
    while(n--)
   {
       scanf("%s%s",a,b);
       flag1=f(a,b);
       if(flag1==0)printf("YES\n");
       else
      {
	 for(i=strlen(b)-1,j=0;i>=0;i--,j++)
	{
	    c[j]=b[i];
	}
	 flag2=f(a,c);
	 if(flag2==0)printf("YES\n");
          else printf("NO\n");
      }
    }
    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