M
M
mentaldeath912020-09-28 12:51:22
Arrays
mentaldeath91, 2020-09-28 12:51:22

How to swap columns in a matrix?

How to swap columns in a matrix? There is a 5x5 matrix. You need to swap the first and second columns. In what ways can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-09-28
@mezastel

If you use rectangular arrays - then only in a loop.
If you are using jagged arrays, then the data in the matrix must be in column-major order so that two columns can be jagged. But usually we use row-major in programming (so that the first index is on the X axis, so to speak), so if you have it, then, again, only cycles will help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question