f77 magic square code 
Author Message
 f77 magic square code

I need help on creating a 5x5 magic sqaure on f77.
If anyone can help!
A magic square is an  N x N matrix in which all
the integers 1,2, . . . N^2
appear exactly once, and all the rows, columns,
and diagonals yield the
same sum.  An example of a 5X5 magic square is
given below (the sum is 65).

                        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

This is the logic I came up with from a Linear
Algebra Book:
I Place an integer 1  in the middle of the top
row.  Then, after placing integer K, move up one
row and to the right one column to place the next
integer  (integer K+1),  UNLESS one of the
following occurs:

If a move takes you above the top row in the jth
column, move to the bottom of the jth column and
place the integer there.

If a move takes you outside to the right of the
square in the ith row,place the integer in the ith
row at the left side.

If a move takes you to an already filled square,
or if you move out of the square at the upper
right-hand corner, place integer K+1 immediately
below integer K.

I need to write a program  that will construct and
print a magic square for
any odd integer N.  In addition to printing the
magic square, it should
also print the row/column/diagonal sum , like 65
in the example above.

If anyone knows/can help with the f77 code, I'd
appreciate it.


Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Wed, 18 Jun 1902 08:00:00 GMT  
 f77 magic square code

Quote:

> If anyone can help!
> A magic square is an  N x N matrix in which all
> the integers 1,2, . . . N^2
> appear exactly once, and all the rows, columns,
> and diagonals yield the
> same sum.  An example of a 5X5 magic square is
> given below (the sum is 65).

>                         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

A fortran program for printing a magic square appeared
in "Algol 60 and Fortran IV" Wiley, 1974 ISBN 0-471-91192-5
which is still in print.

- Show quoted text -



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Magic squares for J

2. Magic Squares

3. Help Please! Magic Square

4. Magic Squares

5. Magic Squares

6. Fill a table (like a magic square)

7. Solving Magic Squares

8. Magic Square

9. any1 done a magic square in c++ using class

10. Magic square

11. Heuristic search routine for Magic-N Squares puzzle?

12. Icetips Magic Entries & Magic Buttons demo

 

 
Powered by phpBB® Forum Software