Hello! Im new to this forum and I come here with a question. I have been following the C++ tutorial from this website and I love it! I have been doing that along with a class in college. C++ 1.
For my project I have to generate a 3x3 grid with numbers from 1 - 9 not repeating and all of the rows have to add to 15.
Now I do not want any hints on how to do this, but I have a question about the random numbers generation. I need to generate a box 2x2.
ex.
But spots 1 and 2's sum must be >= to 6 and <= 14. same applies to spot 1 and 4. Spot 1 and 3. spot 3 and 4. spot 3 and 2 and so on.
Yes I can write this using if statements, but then the program working time will be 30 min as it would have to generate a million random numbers.
My question is, can I generate numbers that will add to 6 or more but not greater than 14?
ex. if my first generated number is 1, then spot two will be generated based on this rule. numbers greater than 3. and if the first number generated is 9 then the rule for generating the second number would be numbers less than 6.
I hope I explained it somehow clear.
Any help is appreciated!
Thanks!
Damian