tutorial7.pptx

# tutorial7.pptx - CSCI1120 Introduction to Compu ting Using...

• 35

This preview shows pages 1–11. Sign up to view the full content.

CSCI1120 Introduction to Compu ting Using C++ Tutorial 7: assignment 3 Li Le SHB 1013 lil @cse.cuhk.edu.hk 1

This preview has intentionally blurred sections. Sign up to view the full version.

Outline Part 1: Basic Requirement Part 2: Problem Introduction Part 3: Analysis of the problem Part 4: Structure of main function Part 5: Sub-functions Part 6: Tips for program 2
1 Basic Requirement Due: 20:00, Wed, 9 Nov 2016 Submit your program named gomoku.cpp to CU eLearning. Decompose your program to have at least four functions (i ncluding main()). At least two functions should have array parameter (s). Your program should be free of compilation errors and war nings. Your program should include suitable comments. No plagiarism! 3

This preview has intentionally blurred sections. Sign up to view the full version.

Outline Part 1: Basic Requirement Part 2: Problem Introduction Part 3: Analysis of the problem Part 4: Structure of main function Part 5: Sub-functions Part 6: Tips for program 4
2.1 Problem Description (a) Gomoku . Starting with an empty N x N square board, two players tak e turns to put discs on the board. The player who first forms a line of five or more consecutive discs wins. In this assignment, a line can along 4 directions: horizontal —, vertical |, northwest-southeast diagonal \, and the nort heast-southwest diagonal /. In the board, ‘O’ denotes player 1’s disc, ‘X’ denotes player 2’s disc, and ‘.’ denotes an empty square. Player 1 puts first. When someone wins or the board is full, print out game res ult. 5

This preview has intentionally blurred sections. Sign up to view the full version.

2.1 Problem Description (b) 13x13 square board Condition to win: consecutive five discs along any line. Consecutive discs should belong to same player Four lines across point (G 8) are shown as follow Horizontal line Vertical line NE-SW line NW-SE line (G 8) 6
2.2 Performance of program in demo 7

This preview has intentionally blurred sections. Sign up to view the full version.

Outline Part 1: Basic Requirement Part 2: Problem Introduction Part 3: Analysis of the problem Part 4: Structure of main function Part 5: Sub-functions Part 6: Tips for program 8
3.1 Board Representation Here requires us to use a 13 x 13 board in this assign ment. It will be represented by a two-dimensional ch ar array . The array elements should be either ‘O’, ‘X’, or ‘.’. char board[N][N]; N is the capacity of board in each dimensio n, here N could be set constantly as a glob al variable: const int N = 13; 9

This preview has intentionally blurred sections. Sign up to view the full version.

3.2 Program flow Empty Board Player input Update board Valid?
This is the end of the preview. Sign up to access the rest of the document.
• Fall '15

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern