联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2019-12-03 09:24

CS2313 Computer Programming

Assignment One

Deadline: 2019-Nov-16 11:59pm

Late submission: 70% (within 24hrs after the deadline), 0% (after 24hrs)

1. Problem description

A “lucky sequence” is the sequence of numbers where every number after the first two

is the sum of the two preceding ones. And a lucky square is a two dimensional array where

all the rows or all the columns are the “lucky sequences”. In this assignment you will write

a program that will determine whether the user inputs a lucky square. The method should

be general enough to accept lucky squares of any size greater than or equal to 1.

Hints:

1. Students may assume all the numbers from the input are non-negative (no need to

check for zero or negative values) and the maximum size of the square is 10. Students

may use 2D array to store the input square, as introduced in the lecture notes for the

program. For example, one can define the input array as int square[10][10]. Then the

element at 2nd row and 3rd column of the lucky square can be stored and accessed by

square[1][2]. Note that arrays in C++ always starts from index 0.

2. The sequence of numbers in a row or col is from lower index to higher index. For

example, if the input array of size 10 is defined as int square[10][10], then the first row is

the sequence of number square[0][0], square[0][1], …, square[0][9].

3. Students may use double for loop to read in user inputs and store into arrays. Student

may use separate arrays to store the test results. Students may use one for loop to test

whether each row or column is a lucky sequence and store the result in the corresponding

arrays mentioned above. Note that the sequence is always a lucky sequence if its length

is smaller than 2. We also assume that the input size of the square is larger than 0 and

smaller or equal to 10, such that there is no need to check the range.

Submitted program will be tested repeatedly by PASS, each time with different input test

case. Note: The program only needs to read in one square. Students do not need to create

loops to handle the 2nd, 3rd square, etc. That is automatically handled by PASS.

2. Program Behavior

When running, the program first prints out the message “Please input the size of the

square:” on a single line. The program then reads the number from keyboard and prints

out another message “Please input the square row by row:”. The program then reads all

the elements of the square. The program then prints whether the rows and columns are

lucky sequences or not. If so, print “Y”. Otherwise, print “N”. Lastly, the program prints

whether the input square is a lucky square or not.

Sample Input / Output: (user input colored in blue)

Example 1 Example 2

Please input the size of the square:

3

Please input the square row by row:

2 4 6

3 5 7

6 9 15

Rows: Y N Y

Cols: N Y N

This is not a lucky square.

Please input the size of the square:

4

Please input the square row by row:

8 12 20 32

5 3 8 11

13 15 28 43

18 1 19 20

Rows: Y Y Y Y

Cols: Y N N N

This is a lucky square.

3. Mark Distribution

Correctness (6 marks)

Submitted program will be tested repeatedly with PASS. Correctness marks will be

graded objectively based on the number of correct outputs reported by PASS.

 If the program cannot be compiled, correctness mark will be zero.

 Make sure that the output format, spelling, spacing, etc., follows exactly the

sample output above. Otherwise PASS may report a very low correct count (or

even zero!). Note that the marker will make NO manual attempt to check or remark

program output.

 Unlike lab exercises, for assignment, PASS will NOT make ALL test cases visible

online, i.e. there are hidden test cases. You should not assume that the report

generated from the “Test” button is your final result.

Good Programming Practice (2 marks)

A maximum of 2 marks are dedicated to good programming styles, including:

 Choice of meaningful variable names.

 Proper use of indentation.

 Meaningful comments (explaining what the code segment or function is doing),

etc.

You may refer to the lecture notes for such good programming styles.

Note that maker will not modify nor fix your submission. Therefore the following cases

may lead to extremely low (or even zero!) marks:

 Submission of non .cpp files (e.g. .exe or .zip files).

 Submission with the “test” function rather than the “submit” function.

 Input/output does not match the requirements as defined.

(e.g. incorrect spacing, incorrect spelling, letter cases or punctuations).

4. Testing and Submission

Students should submit their C++ programs to PASS before the deadline. Students may

use whatever IDE/compiler for their own development, but the source code submitted

must be able to compile in MS Visual Studio. Programs failed to compile in MS Visual

Studio will lead to zero mark. The marker will make no attempt to correct the code and

make it compilable.

It is advised that students test the programs with PASS (using the “test” function) before

final submission (with the “submit” button). Be warned that the system could be

extremely busy and may become sluggish in responding near deadline. Only .cpp files are

accepted. Do not submit .obj , .exe or any other files.

Students should name the .cpp program with their numeric Student ID (e.g.

52345678.cpp). Don’t use EID like tmchan23. It is advised that you write down your

particulars (full name, student number, lab session, and course code CS2313) in the

beginning of your source code as comments.

5. Assessment

This assignment contributes to 8% of the total course marks. This assignment achieves

the following Course ILOs:

1. Explain the structure of an object-oriented computer program;

2. Analyze, test and debug computer programs;

3. Solve a task by applying effective programming techniques, which involve

advanced skills like using recursion and dynamic data structures;

4. Design and construct well-structured programs with good programming

practices.

6. Plagiarism

It is a serious fraud to plagiarize others’ work. Students who committed plagiarism will

be handled according to the global policy of university (http://www6.cityu.edu.hk/ah/).

All suspected plagiarism cases will be reported to the disciplinary body of the University

and not being handled in the course/departmental level.

Students, who plagiarize, as well as those who willfully lent out his/her homework to

others, will receive the same punishment. Confirmed plagiarism cases will result in

disciplinary action, including but not limited to zero marks in coursework.

How to prevent plagiarism?

You can talk about the ideas on how you would do the assignment (at language /

diagram level, but not at source code level). You need to write the program yourself.

Modifying others’ source code (e.g. block rearrangement / variable renaming / merge

source code from multiple classmate, etc,) is also considered as plagiarism.

Protect your code. Do no give away as a reference copy. Your classmate may promise

you that they will only read but not copy your code; however, if later it is observed that

both sources exhibit high level of similarity, you will ALSO be accused of plagiarism for

sure.

How do I get help for programming problems?

There are several ways you can get help:

1. Attend all the lectures and labs.

2. Post your questions (not source code!) to the discussion board in blackboard.

3. Talk to one of the student helpers.

4. Make appointment with your course instructor to discuss your problem.

Note: Debugging, fixing programming errors, is a key activity in this assignment, as

stated in the course ILO #2. Therefore, instructors and student helpers will NOT help

you fix your programming errors. Instead, they will give you high level hints about

finding programming errors, tackling your problems, and directing you to useful

resources such as code examples discussed in lectures and labs.


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp