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 |
水过了六十题,愿以后不再水!!!附上代码,还请大牛们赐教#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator