Computer Programming Assignment One
Late submission: 70% (within 24hrs after the deadline), 0% (after 24hrs)
Copyright By PowCoder代写 加微信 powcoder
1. Problem description
The “spine” of a numeric square is another square of the same size, where all elements except the diagonal ones are zeros, and each diagonal element is the sum of corresponding element in origin square along with all elements at its right and below. In this assignment you will write a program that will generate the “spine” of a given numeric square. The method should be general enough to accept squares of any size greater than or equal to 1.
1. Students may assume all the numbers from the input are non-negative integers and less than 1000 (no need to check for zero or negative values or integer overflow) 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 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 int for loop to read in user inputs and store into arrays. Student may use separate arrays to store the test results. Note that the “spine” of a square is itself if its size is equal to 1. 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 and then prints the “spine” square.
Sample Input / Output: (user input colored inblue)
Please input the size of the square:
Please input the size of the square:
Please input the square row by row:
Please input the square row by row:
8 12 20 32
13 15 28 43
The spine is:
18 1 19 20
The spine is:
Hint: The number 21, in example 1, is obtained by 2 + 4 + 6 + 3 + 6; The number
38, in example 2, is obtained by 3 + 8 + 11 +15 + 1;
Correctness (70%)
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 re- mark program output.
Good Programming Practice (30%)
A maximum of 30% of the 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).
· 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.
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 7% 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.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.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com