Question: This is an assignment I was given for a computer science class. I'm having trouble figuring out how to get specifics to work. I need
This is an assignment I was given for a computer science class. I'm having trouble figuring out how to get specifics to work.
I need to write a C program named stick which plays a matchstick-picking game. Given an initial number of sticks, players take turns picking either 1, 2, or 3 sticks from a pile. Whoever picks the last stick wins.
Usage You run stick with or without command line arguments. i.e. somebody can enter the number of sticks to begin play when the program is launched or they can be prompted after the program begins running. The game should greet the user, and then ask how many sticks to play with (must be an integer >= 10). The user always goes first. On the users turn, ask the user how many sticks to remove, and remove those from the pile. On the computers turn, calculate the correct number of sticks to remove in order to ensure you will (hopefully) win the game. Play continues until there are no sticks left, at which point your program announces who won. You must show the set of sticks after each player's move. Show this as a set of pipes (|) side by side, followed by the number of sticks in (parenthesis).
Illegal Moves When the user is asked how many sticks to take, they must enter 1, 2 or 3. If their entry is illegal (out of range, not a number, or missing), then terminate the program.
Algorithm Your algorithm for picking sticks is simple: given n remaining sticks, pick (n mod 4) sticks, unless (n mod 4)=0; in that case, pick 1 stick.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
