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:Latest! 大侠帮帮忙,怎么wa了呢?

Posted by Nedvid at 2007-09-16 22:23:03 on Problem 3302
In Reply To:Latest! 大侠帮帮忙,怎么wa了呢? Posted by:emperorlu at 2007-08-27 22:41:08
> #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);//就这出现错误了,你的C会有100多个字符传到函数中去,因此循环的时候就会错误,应该另写一个函数,或把你的那个函数修改一下改成两个版本,加一个传递字符长度的函数即可 
> 	 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