Page 1 of 1

Suppose we have a square matrix: int matrix[n][n], where n>0. Can you briefly describe what the code below does (word li

Posted: Fri Jun 10, 2022 11:58 am
by correctanswer
Suppose we have a square matrix: int matrix[n][n], where n>0.
Can you briefly describe what the code below does (word limit:
100)? You may use an example and draw a figure to illustrate your
idea if you want.
Suppose We Have A Square Matrix Int Matrix N N Where N 0 Can You Briefly Describe What The Code Below Does Word Li 1
Suppose We Have A Square Matrix Int Matrix N N Where N 0 Can You Briefly Describe What The Code Below Does Word Li 1 (21.16 KiB) Viewed 88 times
for (int x = n-1; x > -1; x--) { for (int y = 0; y <n; y++) { if (x < n-1 && y > 0) { matrix [x][y] += std::min (matrix [x+1] [y], matrix [x] [y-1]); } else if (x < n-1) { matrix [x][y] += matrix [x+1] [y]; } else if (y > 0) { matrix [x][y] += matrix [x] [y-1]; } std::cout << matrix [0] [n-1] << std::endl;