Hi there,
That's some progress already, well done.
As for your program shutting down, do the following:
1 2 3 4 5 6 7 8
|
int main()
{
do
{
//your code here
} while (1);
return 0;
}
|
For more information on this, the sticky is the 2nd topic in the list on the first page of the "beginners forum".
Now, your code is basically doing something like this:
1 2
|
if x = 1 and y = 4 then print "stand"
if x = 1 then print "hold"
|
Both of these conditions are true, so both "stand" and "print" will be printed.
If/else if/else solves this like so:
1 2 3
|
if x=1 and y=4 then print "stand"
else if x = 4 then print "hold"
else print "game over"
|
This is like saying:
- first check if x is 1 and y=4, if so print stand
- if that is not the case, check if x is 1, without y having to be 4, if so print hold
- if none of the above is true, print game over
This is quite basic stuff, please refer to http://cplusplus.com/doc/tutorial/control/ for more information.
Hope that helps.
All the best,
NwN