#include <iostream>
usingnamespace std;
int main(){
bool n=true;
int i=0;
for (int num1=1 ; num1<50 ; num1++){
for (int num2=2 ; num2<50 ; num2++){
for (int num3=3 ; num3<50 ; num3++){
for (int num4=4 ; num4<50 ; num4++){
for (int num5=5 ; num5<50 ; num5++){
for (int num6=6 ; num6<50 ; num6++){
if (num2 <= num1)
n=false;
if (num3 <= num2)
n=false;
if (num4 <= num3)
n=false;
if (num5 <= num4)
n=false;
if (num6 <= num5)
n=false;
i = i+1;
if (n=true)
cout<<i<<". "<<num1<<" , "<<num2<<" , "<<num3<<" , "<<num4<<" , "<<num5<<" , "<<num6<<"\n";
else (n=true);
}
}
}
}
}
}
return 0;
}
It is a program for generating all the combinations of a gamble in Hong Kong.
It is called Mark Six.
A combination consist 6 numbers ranging from 1 to 49.
No repeating numbers.
I want to make the numbers ordering in ascending order.
But I fail.
No errors existing in the program.
Just cannot order the numbers in ascending order.
What's the problem?
You can remove else statement and that bool variable.
But I think you should do everything differently. Make it so that the next number only counts from where previous number is... Count num2 from "num1+i" while "num1+i <= 49. Do the same for num3 (loop while "num2+i <= 49" and so forth. "i" being variable initialized in each loop (int i=1) except the top-most loop.