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 810974380 at 2009-07-21 11:23:53 on Problem 3302
In Reply To:字符串老WA,放弃它了 Posted by:OSJake at 2009-06-10 15:24:43
我也是啊  测试数据正确    却总是W A 我也不知原因!

 #include<iostream>
#include<cstring>
using namespace std;
int fun(char *a,char *b)
{ int i,j,k,s;char str;
  int l1=strlen(a),l2=strlen(b);
  if(l1<l2) return 0;
  else if(l1==l2)
  {   s=0;
   for(i=0;i<l1;i++)
   if(a[i]==b[i]) s++;
   if(s==l1) return 1;
   else     return 0;
  }
  else{ 
  for(i=0,j=0;i<l1&&j<l2;i++)
   {if(b[j]==a[i]) j++;
    else continue;
   }
   if(j==l2) return 1;
   else {  
    for(k=0;k<l2/2+1;k++)
 { str=b[k];
   b[k]=b[l2-k-1];
   b[l2-k-1]=str;
 } 
    for(i=0,j=0;i<l1&&j<l2;i++)
 {if(b[j]==a[i]) j++;
  else continue;
 }
    if(j==l2) return 1;  
 else return 0;
   }
  }
}
int main()
{ char m[200],n[200];int num,p;
  cin>>num;
  for(p=1;p<=num;p++){ 
   cin>>m>>n;
  if(fun(m,n)==1) 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