combi-test.c 499 B

1234567891011121314151617181920212223242526
  1. #include <stdio.h>
  2. #include "puzzles.h"
  3. int main(int argc, char *argv[])
  4. {
  5. combi_ctx *c;
  6. int i, r, n;
  7. if (argc < 3) {
  8. fprintf(stderr, "Usage: combi R N\n");
  9. exit(1);
  10. }
  11. r = atoi(argv[1]); n = atoi(argv[2]);
  12. c = new_combi(r, n);
  13. printf("combi %d of %d, %d elements.\n", c->r, c->n, c->total);
  14. while (next_combi(c)) {
  15. for (i = 0; i < c->r; i++) {
  16. printf("%d ", c->a[i]);
  17. }
  18. printf("\n");
  19. }
  20. free_combi(c);
  21. }