Rev 2143 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2143 | Rev 8837 | ||
---|---|---|---|
Line 167... | Line 167... | ||
167 | p->val = atoi(argv[argp++]); |
167 | p->val = atoi(argv[argp++]); |
168 | p->used = 1 << i; |
168 | p->used = 1 << i; |
169 | q->next = p; |
169 | q->next = p; |
170 | q = p; |
170 | q = p; |
171 | } |
171 | } |
172 | 172 | ||
173 | printf("Processing "); |
173 | printf("Processing "); |
174 | for (p = results[0]; p; p=p->next) |
174 | for (p = results[0]; p; p=p->next) |
175 | printf("%d ", p->val); |
175 | printf("%d ", p->val); |
176 | printf(". Goal : %d\n", goal); |
176 | printf(". Goal : %d\n", goal); |
177 | 177 | ||
178 | /* 1) results composed by 2 base numbers |
178 | /* 1) results composed by 2 base numbers |
179 | * = res[0] X res[0] */ |
179 | * = res[0] X res[0] */ |
180 | s = &(results[1]); |
180 | s = &(results[1]); |
181 | for (p = results[0]; p->next; p=p->next) |
181 | for (p = results[0]; p->next; p=p->next) |
182 | for (q = p->next; q; q=q->next) |
182 | for (q = p->next; q; q=q->next) |
Line 231... | Line 231... | ||
231 | for (i=0; i<6; i++) |
231 | for (i=0; i<6; i++) |
232 | { |
232 | { |
233 | p = results[i]; |
233 | p = results[i]; |
234 | while (p) |
234 | while (p) |
235 | { |
235 | { |
236 | if |
236 | if (p->val-goal<min) |
237 | { |
237 | { |
238 | best = p; |
238 | best = p; |
239 | min = |
239 | min = p->val-goal; |
240 | } |
240 | } |
241 | if (p->val==goal) |
241 | if (p->val==goal) |
242 | { |
242 | { |
243 | unsigned int tmp = calc_sum(p); |
243 | unsigned int tmp = calc_sum(p); |
244 | if (tmp > biggestsum) |
244 | if (tmp > biggestsum) |