C++ Programming
Assignment
Due Date: March 16, 2005. The program will be corrected during the lab period only.and it solving by function.
i want to say im sorry for writing in english my keybourd cant write arabic i donno why ...
please if anyone can help me to solve these by function it is an assignment..
my major is electrical engineering and i donno anything of c++ thank u very much ... Nader
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
C++ Programming
420-HTX-05
Assignment #2
Due Date: March 16, 2005. The program will be corrected during the lab period only.
____________________________________________________________________________________
The Game of Nim
This is a well-known game with a number of variants. We will consider the following variant.
Two players alternately take marbles from a pile. In each move a player chooses how many marbles to take. The player must take a least one but at most half of the marbles. Then the other player takes a turn. The player who takes the last marble loses.
Input
- Use the input file nimgame.txt in our FirstClass folder. Assume the exact number of records in the file is unknown.
- Each game record contains the first names of each player and the starting pile size.
- The record structure with sample data is shown below.
LISA ZAHEER 7
KRISTINA YULIYA 10
KHALED YANESH 37
KEVIN TIMOTHEE 46
JORDANIE TIAN 27
HUI SHIRAG 15
HADEEL SHERRYL 37
GAVIN SAMER 13
DILBARKHAN ROBERT 78
DAVID PUI 16
CYNTHIA PHILIPPE 95
CRISTIAN PHILIP 78
CRAIG NOEMILIZA 12
CAMELIA NICOLAS 13
BOTHA NAN 65
BOBBY MOHAB 12
ANTONY MARIA 17
Processing
- all variables must be local
- method calls must be pass by value unless pass by reference is required
- process all game records
Functions
main
- declares appropriate variables
- calls the appropriate methods
openInputFile
- opens the input file nimgame.txt
readGameRecord
- read a game record (player names and initial number of marbles in the pile for that game)
playGame
- plays the game to determine the winner and loser
displayGameResults
- display the names of the winner and loser
closeFile
- close the input file
Output
- display the names of the winner and loser for each game