The Game of Nim

hey all im currently writing this program for class and i need some pointers im not sure what direction to go. im a beginning programmer and i just need some guidance. i have the main body of the program working but once the computer starts his turn it gets a little confusing. im not sure what to check for i must have the computer choose a random number from one of three piles and display it. can anyone point me in the right direction?
Last edited on
Do you not know how to generate a random number, or is it something else?
well i know how to generate one but im not sure how to get the computer to pick a random number and output it
the class im taking has no book so im kind of flying blind here
1
2
3
4
5
6
7
8
9
10
// once at the start of main, call this function:
srand( time(0) );


// when you need a random number:
int number = rand() % X;  // 0 <= number < X


// when you want to output it:
cout << number;
thanks that does help also is there any books you all can reccomend for a beginning programmer so i can grasp the basics?
You may want to take a look at Teach Yourself C++ in 21 Days. While it's pre-standard and not that great, it doesn't assume previous programming experience and it's free.

http://newdata.box.sk/bx/c/
Topic archived. No new replies allowed.