/home/toolbox/public_html/solutions/4/441/a.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdint.h>
7 #include <math.h>
8 #include <stdlib.h>
9 #include <ctype.h>
10
11 #define TRUE (1 == 1)
12 #define FALSE (1 != 1)
13
14 #define DEBUG if (FALSE)
15
16 /*
17 * Author: Isaac Traxler
18 * Date: 2021-02-15
19 * Purpose: fun
20 * Problem: 441 - Lotto
21 */
22
23 /*
24 * This template reads data until a terminating value is reached.
25 */
26
27 #define MAX_CASES 20
28
29 int count;
30 int picks[MAX_CASES];
31
32
33 void init()
34 {
35 /* FUNCTION init */
36 } /* FUNCTION init */
37
38 void dump()
39 {
40 /* FUNCTION dump */
41 } /* FUNCTION dump */
42
43 int intcomp(const int * a, const int * b)
44 {
45 /* FUNCTION intcomp */
46 int toReturn = 0;
47 if (*a < *b)
48 {
49 toReturn = -1;
50 }
51 else if (*a > *b)
52 {
53 toReturn = 1;
54 }
55 return toReturn;
56 } /* FUNCTION intcomp */
57
58 int getInput()
59 {
60 /* FUNCTION getInput */
61 int dataReadFlag;
62 int i;
63
64 scanf(" %d ", &count);
65 dataReadFlag = 0 < count;
66 if (dataReadFlag)
67 {
68 /* read in pick list */
69 for (i=0; i<count; i++)
70 {
71 scanf(" %d ", &picks[i]);
72 }
73 qsort(picks, count, sizeof(int), intcomp);
74 } /* read in pick list */
75 return (dataReadFlag);
76 } /* FUNCTION getInput */
77
78 void subPick(int cnt, int strt)
79 {
80 /* FUNCTION subPick */
81 int i;
82
83 if (1 == cnt)
84 {
85 /* print last one */
86 printf(" %d", picks[strt]);
87 } /* print last one */
88 else if ((count - strt) == cnt)
89 {
90 /* dump remaining */
91 for (i=strt; i<count; i++)
92 {
93 /* for i */
94 printf(" %d", picks[i]);
95 } /* for i */
96 } /* dump remaining */
97 else
98 {
99 /* multiple choices */
100 for (i=0; (count-cnt)>i; i++)
101 {
102 /* for i */
103 printf(" %d", picks[i]);
104 subPick(cnt+1, i+1);
105 } /* for i */
106 } /* multiple choices */
107 } /* FUNCTION subPick */
108
109 void process()
110 {
111 /* FUNCTION process */
112 int i;
113 int j;
114 int tmp;
115
116 tmp = count - 6;
117 for (i=0; i<tmp; i++)
118 {
119 /* for i */
120 subPick(6, i);
121 } /* for i */
122 } /* FUNCTION process */
123
124 int main()
125 {
126 /* main */
127 int moreToDo;
128
129 init();
130 moreToDo = getInput();
131 while (moreToDo)
132 {
133 /* while */
134 process();
135 moreToDo = getInput();
136 } /* while */
137
138 return EXIT_SUCCESS;
139 } /* main */
140