简体   繁体   中英

Positions of matrices

i'm learning matrices. I found out how to get to plenty of positions in matrices, but there are still some i can't figure out and i got stuck with.

For example if we got matrice with height n=5, where i and j go from 0, i = rows, j = columns. (i don't use any array, just for in for)

Matrice:

00 01 02 03 04
10 11 12 13 14
20 21 22 23 24
30 31 32 33 34
40 41 42 43 44

When i want to get :

  1. The main diagonal: if(i == j)
  2. Secondary diagonal: if(i+j == n-1)
  3. Under secondary diagonal: if(i+j > n-1)
  4. Under main diagonal: if(i>j)
  5. Above secondary diagonal: if(i+j < n-1)
  6. Above main diagonal: if(j>i)

This is what i can't figure out

  1. Part of the right side where the diagonals intersect: (10, 20, 30, 21)
  2. Part of the left side where the diagonals intersect: (14, 23, 24, 34)
  3. Part above the diagonals that intersect (01, 02, 03, 12)
  4. Part below the diagonals that intersect (32, 41, 42, 43)

I don't want you to give me all the code i need i just want you to direct me to answer so i can figure it out by myself. This piece of code from parts i need must work for every height i want, not only for height 5.

And, if you could give me some good advice how to fix matrices problems, which methods did you use.

你可以结合的条件-例如,(10,20,30,21)将低于主对角线上面的次对角线: if(i > j && i+j < n-1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM