提供高质量的essay代写,Paper代写,留学作业代写-天才代写

首頁 > > 詳細

data程序代做、代寫C++程序設計、c/c++編程語言調試代寫Python程序|代做留學生Prolog

Computing Machinery I
Assignment 1
8% of your final score
Lead TA
The lead TA for this assignment is Abdullah Sarhan asarhan@ucalgary.ca
Objective
The objective of this assignment is to practice basic C concepts, including 2D arrays, random numbers, and
searching.
Note
It is your responsibility to make sure your code runs on arm.cpsc.ucalgary.ca. Code tested on your
laptop or even linux.ucalgary.ca may not run as desired on arm.cpsc.ucalgary.ca. We will
test your code on the arm servers and we will follow the published marking rubric.
Skills needed for this assignment
• Ability to work with 2D arrays in C
• Ability to use a random number generator
• Ability to employ a searching algorithm
• Ability to use command-line arguments
• Ability to write and read text files in C
• Ability to define functions in C
• Ability to pass parameters by value and by reference
Overview
Your program will implement a simple memory game. The user attempts to match face-down cards. If the
user guesses wrong, the program provides hints.
Details
The game board is a 2D array. The size of which is 2Nx2N where N is a number provided by the user as a
command-line argument. For instance, the program can be started as to initialize a 4x4 grid:
./assign1.o playerName 2
To initialize the values in the board array, follow the steps:
1. Create an array cards of size 2N*N such that card[i] = i.
2. Shuffle the array cards using the following simple algorithm:
for (i = 0; i <2N-2; i++) {
j = random(i,n2*N*N-1); // generate a random number j such that i ? j ? n2*N*N-1
swap(cards[i],cards[j]);
}
3. Copy cards to board, one row at a time, starting from row 0.
4. Shuffle cards again
5. Copy cards to the second half board
Once board is initialized print it to the screen:
0 3 7 2
5 6 1 4
3 5 1 2
4 6 0 7
Wait for the user to hit return, then hide your board displaying them face down:
X X X X
X X X X
X X X X
X X X X
You need to clear the screen; you can call Linux clear command from your program as:
system("clear");
The user then selects a card to uncover:
Enter the coordinates of a card: 0 3
The board is re-printed showing card (0,3) uncovered:
X X 7 X
X X X X
X X X X
X X X X
Enter the coordinates of a card: 2 3
X X 7 X
X X X X
X X X 2
X X X X
The user in this example missed to match card 7. So, a hint is provided:
You are 1 card away!
Press any key to continue …
Note that “one card away” means that 7 could be in any of the immediate neighbors of card (2,3). That is,
any of (3,3), (1,3), or (2,2).
When the user continues the game, the mismatched card is flipped back to face down:
X X 7 X
X X X X
X X X X
X X X X
Enter the coordinates of a card: 3 3
This time the user guesses right and the matched cards remain revealed until the end of the game
X X 7 X
X X X X
X X X X
X X X 7
Enter the coordinates of a card:
The user can play the game until all cards are matched, the score becomes 0, or they decide to quit. The
user exists the game by entering q or Q.
The score is calculated as follows. A user starts with a score of 2N. A match adds N points to the score. A
miss subtracts 1 point.
When the user exists or the game ends, the player name and score are recorded in a text file.
Modularity
Your code must be divided into functions as appropriate. At a minimum, you must define the following
functions (we are not showing all necessary arguments, but what is shown must be used as shown):
- initialize(*board)
- shuffle(*cards)
- swap(*cards, i, j)
- randomNum(n,m); n and m are the inclusive lower and upper bounds for the random
number. You can use the C library function rand().
- display(*board)
- findDistance(*board, i1, j1, i2, j2); returns the distance between cards (i1,j1)
and (i2,j2). This distance is 0 if it is a hit; otherwise, the value is used to provide a hint to the user.
- logFile(*playerName, score)
Submission
• Note: The TA may provide further submission instructions
• Name your program assign1.c
• Create a script file and call it assign1.script
• Name your log file assign1.log
• You may submit a README file providing extra instructions or information for your TA
[optional]
• Submit your work to the appropriate dropbox on D2L.
Late Submission Policy
Late submissions will be penalized as follows:
-12.5% is applied for each late day or portion of a day.
Hence, no submissions will be accepted after 8 days (including weekend days) of the announced deadline.
Academic Misconduct
This assignment is to be done by individual students: your final submission must be your own original
work. Teamwork is not allowed. Any similarities between submissions will be further investigated for
academic misconduct. If you discuss the assignment with your colleagues, this must be limited to highlevel
conceptual and design decisions. Code (including pseudo-code) sharing by any means is prohibited,
including but not limited to looking at someone else’s paper or screen, reading code to someone, or reading
pseudo-code. The submission of compiler generated assembly code is absolutely prohibited. Any re-used
code of excess of 5 lines in C and 10 lines in assembly (10 assembly language instructions) must be cited
and have its source acknowledged. Failure to credit the source will also result in a misconduct
investigation.
D2L Marks
Marks posted on D2L are subject to change (up or down).

聯系我們
  • QQ:1067665373
  • 郵箱:1067665373@qq.com
  • 工作時間:8:00-23:00
  • 微信:Badgeniuscs
熱點文章
程序代寫更多圖片

聯系我們 - QQ: 1067665373 微信:Badgeniuscs
? 2021 uk-essays.net
程序代寫網!

在線客服

售前咨詢
售后咨詢
微信號
Essay_Cheery
微信
全优代写 - 北美Essay代写,Report代写,留学生论文代写作业代写 北美顶级代写|加拿大美国论文作业代写服务-最靠谱价格低-CoursePass 论文代写等留学生作业代做服务,北美网课代修领导者AssignmentBack 北美最专业的线上写作专家:网课代修,网课代做,CS代写,程序代写 代码代写,CS编程代写,java代写北美最好的一站式学术代写服务机构 美国essay代写,作业代写,✔美国网课代上-最靠谱最低价 美国代写服务,作业代写,CS编程代写,java代写,python代写,c++/c代写 代写essay,作业代写,金融代写,business代写-留学生代写平台 北美代写,美国作业代写,网课代修,Assignment代写-100%原创 北美作业代写,【essay代写】,作业【assignment代写】,网课代上代考