标签:des style http color os io strong for
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 6291 | Accepted: 3995 |
Description
Input
Output
Sample Input
7 1 2 3 4 5 6 7 8 1 2 3 5 8 13 21 34 0
Sample Output
1 2 3 4 5 6 1 2 3 4 5 7 1 2 3 4 6 7 1 2 3 5 6 7 1 2 4 5 6 7 1 3 4 5 6 7 2 3 4 5 6 7 1 2 3 5 8 13 1 2 3 5 8 21 1 2 3 5 8 34 1 2 3 5 13 21 1 2 3 5 13 34 1 2 3 5 21 34 1 2 3 8 13 21 1 2 3 8 13 34 1 2 3 8 21 34 1 2 3 13 21 34 1 2 5 8 13 21 1 2 5 8 13 34 1 2 5 8 21 34 1 2 5 13 21 34 1 2 8 13 21 34 1 3 5 8 13 21 1 3 5 8 13 34 1 3 5 8 21 34 1 3 5 13 21 34 1 3 8 13 21 34 1 5 8 13 21 34 2 3 5 8 13 21 2 3 5 8 13 34 2 3 5 8 21 34 2 3 5 13 21 34 2 3 8 13 21 34 2 5 8 13 21 34 3 5 8 13 21 34
Source
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=50+10;
int a[maxn],n,ans[maxn];
void dfs(int ith,int num)
{
if(num==6)
{
for(int i=1;i<=5;i++)
printf("%d ",ans[i]);
printf("%d\n",ans[6]);
return;
}
//if(num+n-ith<6) return;
for(int ai=ith+1;i<=n;i++)
{
ans[num+1]=a[i];
dfs(i,num+1);
}
}
int main()
{
while(~scanf("%d",&n))
{
if(n==0) return 0;
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
sort(a+1,a+1+n);
for(int i=1;i<=n;i++)
{
ans[1]=a[i];
dfs(i,1);
}
printf("\n");
}
return 0;
}
poj2245Lotto(最基础的dfs),布布扣,bubuko.com
标签:des style http color os io strong for
原文地址:http://blog.csdn.net/u014303647/article/details/38412549