Thread: magic array

  1. #1
    Registered User scuba22's Avatar
    Join Date
    Oct 2002

    magic array

    hi all...
    I am trying to write an array matrix that will pull in a number that defines the array size of rows and cols (like #3 means 3 rows 3 cols)
    and then wrap numbers around the matrix so that the sum diag, across and down are all equal

    here is the #3 example:

    8 1 6
    3 5 7
    4 9 2

    the sum is 15.

    supposedly the number 1 needs to be in the middle row of col 1.
    and each successive int up one and over one.

    I have been provided with an external file of 6 numbers each that are to be used to make a searate matrix.

    I am totally lost.
    My first 2d array program was before this and i could pull in data from an external file print as a matrix and like this arr[1][2]...
    but i am completely at a loss as to where the other numbers
    in the array come from...
    the instructions are:
    write a program that prints a magic cube as well as it's magic sum for an odd integer s greater than 1 but less than 17.
    maybe the instuctions are vague or I am just stupid..I am not asking for anyone to do my homework- i am asking for help understanding WHAT to do...
    someone with experience out there MUST know what it's like to
    look at a question and get a big ? in their head???
    thanks a lot

  2. #2
    Registered User
    Join Date
    Nov 2001
    I do not know of a mathematical shortcut. My solution is to create, for example, a 4x4 array and change the elements in the first 3 rolls and first 3 columns until you get the correct sum for all rolls, columns, and diagonals.


  3. #3
    Registered User scuba22's Avatar
    Join Date
    Oct 2002


    i'll try...
    what would it be called?
    sorry, I am really green an feeling stupid

  4. #4
    Registered User scuba22's Avatar
    Join Date
    Oct 2002

    Thumbs up wow

    wow...thank you!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  5. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 04:27 PM