| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么会WA呢...无语了啊!!!!!!大虾救命啊!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator