Exforsys
+ Reply to Thread
Results 1 to 2 of 2

asking c code for magic square of 3*3

This is a discussion on asking c code for magic square of 3*3 within the C and C++ forums, part of the Programming Talk category; sir, I want to ask the c code for 3*3 square matric code. and also the c code for * ...

  1. #1
    jagdish pimoli is offline Junior Member Array
    Join Date
    Aug 2007
    Answers
    1

    asking c code for magic square of 3*3

    sir, I want to ask the c code for 3*3 square matric code.
    and also the c code for



    *
    **
    **
    **
    **
    ***


  2. #2
    priyaraji is offline Member Array
    Join Date
    Apr 2006
    Answers
    52
    I am giving the algorithm for generating magic square of size n*n where n is odd. You can substitute n=3 in your case.

    * First start with one in the middle of the first row

    * Then traverse left and then go up and left. In these place numbers to empty squares in order of increasing.

    * If suppose you reached the first column then move to the last column of the same row and in the same manner for the first row move to the last row of the same column.

    * Proceed and if the square is filled already move down and continue till all is finished.

    Try this algorithm and let me know if you need any help.


Latest Article

Network Security Risk Assessment and Measurement

Read More...