Thread: damn arrays

  1. #1
    Unregistered
    Guest

    Unhappy damn arrays

    Hi everyone,

    Can anyone tell me how I would turn a 64x64 array into a 3x4096 array. The first column needs to contain the x co-ord of the element the second column contains the y co-ord of the element and the third column needs to contain contain the value of that element.

    Any help would be great!

    Thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Something like
    Code:
    for ( r = 0 ; r < 64 ; r++ ) {
      for ( c = 0 ; c < 64 ; c++ ) {
        pos = r * 64 + c;
        new[pos][0] = r;
        new[pos][1] = c;
        new[pos][2] = old[r][c];
      }
    }

  3. #3
    Unregistered
    Guest
    Thanks for that Salem but could you possibly explain whats going on there.

    cheers

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > The first column needs to contain the x co-ord
    Is this line....
    new[pos][0] = r;

  5. #5
    Unregistered
    Guest
    ah ok, thats excellent.

    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  2. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  3. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  4. Help with arrays and pointers please...
    By crazyeyesz28 in forum C++ Programming
    Replies: 8
    Last Post: 03-17-2005, 01:48 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM