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

大牛帮帮忙 怎么老是WA是不是有比较偏的数据没有考虑到啊?谢谢啊

Posted by howling at 2011-07-11 18:46:41 on Problem 3302
#include<iostream>
int sub(char ch1[],char ch2[]){
    int len1=strlen(ch1);
    int len2=strlen(ch2);
    int i=0;
    int j=0;
    
    int count=0;
    
    for(i=0;i<len2;i++){
       
        for(j;j<len1;j++){
            if(ch2[i]==ch1[j]){
                
                j++;
                count++;
                break;
            }
        }
        
    }
    if(count==len2){return 1;}
    j=0;
    count=0;
    for(i=len2-1;i>=0;i--){
        for(j;j<len1;j++){
            if(ch2[i]==ch1[j]){
                
                count++;
                j++;
                break;
            }

        }
    }
    if(count==len2)return 1;
    else return 0;


}
using namespace std;
int main (){
    int n;
    char ch1[10],ch2[10];
    
    cin>>n;
    while(n--){
        cin>>ch1>>ch2;
        if(sub(ch1,ch2))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    system("pause");
    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