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 handsome8848 at 2008-10-19 18:39:52 on Problem 3049
#include <cstdio>
#include <iostream>

using namespace std;

void search(int ,int k);
int path[30];
bool satisfy();


         int l,c,cnt=0,
           alph[30]; 
         
         int main()    {
             
           int i;
           char ch;
           
           scanf("%d%d",&l,&c);
           
           for(i=1;i<=c;i++) {cin>>ch;alph[i]=int(ch);}
           sort(alph,alph+c);
           
           search(1,l);   
                                 
    return 0;                            
                                
   
}
void search(int s,int k){
     
     int i;
     
     if(k==0) {if (satisfy())       { for (i=1;i<=l;i++) printf("%c",char(path[i]));printf("\n");}
     return ;
     }
     
     for(i=s;i<=c+1-k;i++)
     {
                  path[++cnt]=alph[i];
                  search(i+1,k-1);
                  cnt--;
                  }
     }  
     
bool satisfy(){
     int j,vowel=0;
     for(j=1;j<=l;j++) 
     if(path[j]=='a' ||path[j]=='e' ||path[j]=='i' ||path[j]=='o' ||path[j]=='u' ) vowel++;
     
     if(vowel>0 && l-vowel>1) return true;
     else return false;}
     
     

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