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

我已癫狂 大牛快来救救我,discuss里的情况我都有考虑而且给的数据都已经过了为什么还WA啊

Posted by howling at 2011-07-12 12:03:07 on Problem 1318
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int cmp(char ch1[],char ch2[]){
    int len1=strlen(ch1);
    int len2=strlen(ch2);
    int sum=0;
    int r[10];
    memset(r,0,sizeof(r));
    
    if(len1!=len2)return 0;
    
    for(int i=0;i<len2;i++){
        
        for(int j=0;j<len1;j++){
            if(r[j]==0&&ch2[i]==ch1[j]){
                
                r[j]=1;sum++;break;
            }
        }
    }
    if(sum==len2)return 1;
    return 0;
}
int comp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}


int main (){
    char a[10];
    char map[100][10];
    char str[10];
    memset(str,'X',sizeof(str));
    char end[6];
    memset(end,'*',sizeof(end));
    
    int i=0;
    
    cin>>map[i];
    
    
    
    while(strcmp(map[i],str)==1){
        
        i++;
        cin>>map[i];
    }
    qsort(map,i,sizeof(char)*10,comp);
    cin>>a;
    while(strcmp(a,str)==1){
        int flag=0;
        
        for(int j=0;j<i;j++){
            if(cmp(map[j],a)==1){cout<<map[j]<<endl;flag=1;}

        }
        if(!flag)cout<<"NOT A VALID WORD"<<endl;
        cout<<end<<endl;
        cin>>a;
    }
    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