Page 1 of 1

C++ Random Matrix Generator The program is to receive 2 command line parameters from the user, row and col. Suppose that

Posted: Mon May 09, 2022 7:11 am
by answerhappygod
C++ Random Matrix Generator
The program is to receive 2 command line parameters from the
user, row and
col. Suppose that
row and col are
both integers, and 5 ≤ row ≤ 10, 10 ≤
col ≤ 20.
Next, in the main function, the program needs to dynamically
generate a 2D array matrix using
new, the size of which is
row × col.
Then, define an additional function
matrix_initialization(). Please use a
pointer to pass matrix to this
function. Plus, this function returns void.
Specifically, inside
matrix_initialization(), the program
needs to use positive random integers to initialize
matrix. Furthermore, for all elements in
any row, the sum of them must be 100.
Finally, your main function should output the resulting
matrix. Please don’t forget to release
the allocated memory before the end of the program.
Requirement: When accessing the element in the
2D array, the program must use pointer. NO
USE of an index like matrix[j].
Avoid using advanced syntax.
The resulting matrix should look like this:
50 10 9 13 11 7
17 15 43 15 4 6
20 10 26 8 2 34
34 6 2 1 47 10
29 24 5 1 21 20
7 6 20 4 2 61
12 13 16 2 52 5
4 8 23 2 30 33
13 7 10 2 48 20
23 22 7 1 17 30