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

水过了六十题,愿以后不再水!!!附上代码,还请大牛们赐教

Posted by SkyOrNight at 2011-04-06 18:48:30 on Problem 2245
#include<stdio.h>
#include<string.h>
int K;
int nums[13];
int chosed[13];
void find(int st,int n);
int main(void){
    int i,count=0;
	freopen("in.txt","r",stdin);
    while(scanf("%d",&K)!=EOF&&K){
        for(i=0;i<K;i++) scanf("%d",&nums[i]);
		count++;
		if(count!=1)
		  printf("\n");
		memset(chosed,0,sizeof(chosed));
		find(0,0);
    }
    return 0;
}
void find(int st,int n){
     int i,j,count;
	 if(n==6){
		 count=1;
		 for(i=0;i<K;i++){
			 if(chosed[i]){
				 if(count==1) printf("%d",nums[i]);
				 else printf(" %d",nums[i]);
				 count++;
			 }
		 }
		 printf("\n");
		 return;
	 }
	 for(i=st;i<K;i++){
		 if(!chosed[i]){
			 chosed[i]=1;
			 find(i+1,n+1);
			 chosed[i]=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