Reputation: 25
I need to make a program for a LoShu Magic Square. The User has to input the numbers 1-9, into the array, but they cannot repeat any of the numbers. I have tried using multiple while loops, but that didn't work completely. How would I solve this problem?
Upvotes: 2
Views: 53
Reputation: 132
do{ // get the user input }while(condition) // test if the entred data is in the vector, if it is not exit the loop // after exitting the loop add the element to the vector
This will ensure that the user want enter a number already exists in the vector. If you want the user to enter multiple numbers just add a uper while loop (infinite loop)
Upvotes: 1