0

Who is the best in c++ show me the solution of this question

Write a program to convert a 2D array “A” to 1D array “a” using row-major order and column-major order

12th Oct 2019, 3:33 PM
Abdulelah
Abdulelah - avatar
1 Answer
+ 1
The size of a 1D array corresponding to a 2D array would be columns * rows, and the indexing can be converted by using the formula row * totalColumns + column. The rest is simple copy pasta by using for loops, either you iterate over the rows before the columns for a row major order in the 1D array, or you iterate over the columns before the rows for a column major order. Example program: https://code.sololearn.com/c45xDJNiG87C/?ref=app
12th Oct 2019, 4:04 PM
Shadow
Shadow - avatar