Posted on 2008-03-27 00:34
superman 阅读(156)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1089 C++ 00:00.03 840K */
2 #include <string.h>
3 #include <iostream>
4
5 using namespace std;
6
7 int n, set[20];
8
9 bool x[20];
10 void search(int i, int j)
11 {
12 if(j > 6)
13 {
14 int count = 0;
15 for(int i = 1; i <= n; i++)
16 if(x[i])
17 {
18 count++;
19 cout << set[i] << (count == 6 ? '\n' : ' ');
20 }
21 return;
22 }
23 if(i > n)
24 return;
25 if(6 - j <= n - i)
26 {
27 x[i] = 1;
28 search(i + 1, j + 1);
29 x[i] = 0;
30
31 search(i + 1, j);
32 }
33 }
34
35 int main()
36 {
37 cin >> n;
38 while(1)
39 {
40 memset(x, 0, sizeof(x));
41 for(int i = 1; i <= n; i++)
42 cin >> set[i];
43
44 search(1, 1);
45
46 cin >> n;
47 if(n)
48 cout << endl;
49 else
50 break;
51 }
52
53 return 0;
54 }
55