Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

C# Program need to be made


thyownage
 Share

Recommended Posts

Well heres the programs I have to make… It would be great if someone new how to make these and could give me the code, thx.

1\. Write a program to perform the following tasks:
a. Ask the user for the dimensions of a 2D array.
b. Declare a 2D array of the appropriate size.
c. Read in values for all of the elements
d. Add up the diagonals of the array
e. Print the sum of the diagonals
f. Print the array
2\. Write a program that generates magic squares. From Wikipedia: “In recreational mathematics, a magic
square of order n is an arrangement of n2 numbers, usually distinct integers, in a square, such that the n
numbers in all rows, all columns, and both diagonals sum to the same constant.[1] A normal magic
square contains the integers from 1 to n2\. The term "magic square" is also sometimes used to refer to any
of various types of word square.”
To create an n x n magic square, where n is odd, follow the following algorithm:
a. place the value of 1 at row 0 and column n/2 + 1
b. The next value goes 1 row up and 1 row to the right
c. If there is difficulty in placing the new element, follow these rules
i. If the new row is –1, place the value in the last row
ii. if the column is n, then place the value in column 0
iii. if the element is [0, n-1] then drop down one row
iv. if the position is already occupied, drop down one row
d. Repeat n * n times
Example of 5 * 5
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
Input for program: n
Output: n x n magic square
Link to comment
Share on other sites

@[SB:

> Fruitpunch link=topic=54842.msg580636#msg580636 date=1259631282]
> if you cannot make this yourself then you fail, end of story, this thread should be locked

That's not very nice.. I definitely can't write these, does that mean that I "fail" too?

thyownage: You have everything that you need defined already in your topic, putting it all together should be a simple matter of looking up the strings and variables and piecing them together no?
Link to comment
Share on other sites

This again? Seriously, I'm happy helping you out with anything your confused with… but I'm not writing the whole thing for you again (one time thing). If you tried it yourself and wanted opinions/help that would be different... but you cant just post up your homework and have the world solve your problems.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...