I am in the process of creating a game that has two players machine and person. The player is selected randomly each round. So if the player is selected, he needs to choose a number from 1-9. Then the machine needs to choose another new number either in the same row or colunm.(i figured out how to check against col.and row). Then keep going until someone reaches 31.
I´m stuck on how to add the numbers from previous rounds and have them reflect in the new rounds. While at the same time using the last entered number(ultimo) as a reference has to whether or not the new number is valid.
Ok I created a while loop as suggested. But it is not adding each round like it should. So the question is: What is wrong with the code after the while loop?
while ((x != 0) && (suma < Meta)){
cout << "SUM =" << x + last number << endl;
if (player == Person) {
x = machinerandomnDigit(last number);
sum = sum + x;
player = Person;
last number = x;
}
else {
x = machinerandomDigit(ultimo);
sum = sum + x;
player = Person;
last number = x;
}
}
cin.sync();
cin.get();
system("pause");
return whoStarts();