Printing every combination of the powerball

I want to store them on to a file.
I don't want duplicates.

My method
Print all 292 million combinations and place it into the file.
open the file and compare all the combinations, if there are duplicates I erase them.(nested loop)
but i would have to do string to int conversion

I already showed you how to do this in a previous post. Here it is again. It doesn't print any duplicates. Every combination is unique.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>

const int WhiteMax = 69;
const int PowMax   = 26;

void print(int a, int b, int c, int d, int e, int p) {
  std::cout << a << ' ' << b << ' ' << c << ' '
            << d << ' ' << e << ' ' << p << '\n';
}

int main() {
  for (int a = 1; a <= WhiteMax-4; a++)
    for (int b = a + 1; b <= WhiteMax-3; b++)
      for (int c = b + 1; c <= WhiteMax-2; c++)
        for (int d = c + 1; d <= WhiteMax-1; d++)
          for (int e = d + 1; e <= WhiteMax; e++)
            for (int p = 1; p <= PowMax; p++)
              print(a,b,c,d,e,p);
}

Topic archived. No new replies allowed.