-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCombinations.cpp
More file actions
61 lines (61 loc) · 1.12 KB
/
Copy pathCombinations.cpp
File metadata and controls
61 lines (61 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <vector>
#include <fstream>
#include <map>
#include <bitset>
#include <cstring>
using namespace std;
#define ll long long int
#define INF 2147483647
#define PI acos(-1.0)
#define EPS 1e-9
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, ll> llp;
typedef pair<double, double> iid;
int k;
int a[25];
void combinations(int ans[], int start, int elem)
{
if(elem==6)
{
for(int i=0;i<6;++i)
{
if(i>0)
printf(" ");
printf("%d", ans[i]);
}
putchar('\n');
return;
}
for(int i=start; i<k; ++i)
{
ans[elem++]=a[i];
combinations(ans, i+1, elem);
elem--;
}
}
int main()
{
bool flag=false;
while(1)
{
scanf("%d", &k);
if(!k)
break;
for(int i=0;i<k;++i)
scanf("%d", &a[i]);
int ans[10];
if(flag)
putchar('\n');
flag=true;
combinations(ans, 0, 0);
}
}