CECS 282
LAB ASSIGNMENT 3
Assigned date: 9/7
Due date: 9/14
45 points
Problem 1 [15 points] Monday 9/12
Write a program that remove duplicates from an array. You are required to create functions that has an array as an arguments.
Problem 2 [30 points] Wed 9/14
A square is called a magic square if the sum of the elements in each row, in each column, and in the two diagonals is the same value. For example
16 3 2 13
5 10 11 8
9
6 7 12
4
15 14 1
Implement the following algorithm to construct magic n x n squares. It works only if n is odd. Place a 1 in the middle of the bottom row. After k has been placed in the (i,j) square, place k+1 into a square to the right and down, wrapping around the borders. However, if you reach a square that has already been filled, or if you the lower right corner, then you must move one square up instead. Here is the 5 x 5 square that you get if you follow this method:
Enter an odd number: 5
11 18 25 2 9
10 12 19 21 3
4 6 13 20 22
23 5 7 14 16
17 24 1 8 15
You are required to create functions that has an array as an arguments.
Note: The problem is created by Cay Horstmann from the book C++ for everyone.
Grading