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:官方的解法

Posted by 2239457083 at 2016-03-07 22:30:07 on Problem 1035
In Reply To:官方的解法 Posted by:donkeyinacm at 2009-11-26 13:48:50
> #include <iostream>
> 
> using namespace std;
> 
> #define MAX 10010
> #define MAXL 20
> 
> char D[MAX][MAXL];
> int Dp;
> char C[MAXL];
> 
> 
> 
> 
> 
> 
> 
> bool replace(char *A,char *B)
> {
>  int l1=strlen(A);
>  int l2=strlen(B);
>  int i=0;
>  if(l1==l2)
>  {
>   while(i<l1&&A[i]==B[i])
> 	  i++;
>   while(++i<l1)
> 	  if(A[i]!=B[i])
> 	  return false;
>  }else if(l1==l2+1)
>  {
>    while(i<l2&&A[i]==B[i])
> 	  i++;
>   
>    while(++i<l1)
>     if(A[i]!=B[i-1])
> 		return false;
>  }else if(l1+1==l2)
>  {
>    while(i<l1&&A[i]==B[i])
> 	   i++;
>   
>    while(++i<l2)
> 	   if(A[i-1]!=B[i])
> 		   return false;
>  }else
> 	 return false;
> 
> return true;
> }
> 
> int main()
> {
> 	//freopen("c:/aaa.txt","r",stdin);
> 
>  Dp=0;
>  while(scanf("%s",D[Dp++])&&strcmp(D[Dp-1],"#")!=0)
> 	 ;
>  Dp--;
>  while(scanf("%s",C)&&strcmp(C,"#")!=0)
>  {
> 	 bool Found=false;
>   for(int i=0;i!=Dp;i++)
>    if(strcmp(D[i],C)==0)
>    {
>     Found=true;
> 	break;
>    }
> 
>  if(Found)
> 	 printf("%s is correct\n",C);
>  else
>  {
> 	 printf("%s:",C);
>  for(int i=0;i!=Dp;i++)
> 	 if(replace(D[i],C))
> 		 printf(" %s",D[i]);
> 	 printf("\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