Thread: array of vectors

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    20

    Unhappy array of vectors

    I need to make a function to initalize the diagonals of an array of 10 vectors to any one floating point number passed as a parameter. The part that I'm unsure of is to initalize the diagonals, how would this be done?
    Thanks
    K

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    One solution is a loop. Given there is a 10x10 matrix, here is one solution.

    Code:
    int nCol = 0;
    
    // Top left to lower right
    for (int i = 0; i < 10; ++i)
       array[i][i + nCol++];
    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. array of pointers/pointer arithmetic
    By tlpog in forum C Programming
    Replies: 18
    Last Post: 11-09-2008, 07:14 PM
  2. Have problems with copying my array!
    By AvaGodess in forum C Programming
    Replies: 11
    Last Post: 09-25-2008, 12:56 AM
  3. 1-D array
    By jack999 in forum C++ Programming
    Replies: 24
    Last Post: 05-12-2006, 07:01 PM
  4. Arrays vs Vectors
    By swgh in forum C++ Programming
    Replies: 5
    Last Post: 05-04-2006, 02:06 AM
  5. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM