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

Printable View

- 02-23-2003bearcat19array 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 - 02-23-2003kuphryn
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++];