الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Please help me to solve this

مغلق
بدأه nado0o84 في 14 مارس 2005 · 4 رد · 536 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

#2

you don't know anything of C++?! well, you should learn it. there is no point in us doing your homework

#3

Hi Hasan_aljudi :

ok i'll do my homework and i should learn it of course if i not i will fail this course ..

but i just want an idea of how i can solve these..

this is the first time i took this course and in fact its is a big problem to me to do it i don't know how i solve this ...

if u please can give me an idea for how i can solve these and thank u for answering me back ... Nader

#4

well first of all, I apologize for being rude, but these things are a bit adanced and I don't know if you can implement them, do you have any experience in any other language? if not, then it's gonna be tough.

For the records file, you're probably gonna need a linked list of a struct which has two elements, a string and an integer.

you're gonna have to open the file and parse it line by line, at each itration, read the name and the number of piles, dynamically create a new instance of the structure and add it to the list (you could use a class instead of a structure and let the constructor add "this" to the list).

as for the game itself, I have no idea how it plays, so I can't really help on that.

for actual C++ tutorials, there are lots, but here:

http://www.cplusplus.com/doc/tutorial/

http://www.cprogramming.com/tutorial.html

here's a linked list tutorial:

http://www.fortunecity.com/skyscraper/fals...0/linklist.html

for opening files, here's one tutorial:

http://www.cpp-home.com/FileIO_tutorial.php

but apparently this will disappear soon, so here is another one:

http://www.codersource.net/cpp_file_io.html

and

http://www.cprogramming.com/tutorial/lesson10.html

and maybe this one is better

http://www.gamedev.net/reference/articles/article1127.asp

#5

actually i don't know other programming language and its been very difficult to me because i think i must solve by function way ..

thank u very very much Mr Hasan for helping me and Have good luck ..

هذا الموضوع مغلق.

مواضيع مشابهة