- Suppose We Have A Square Matrix Int Matrix N N Where N 0 Can You Briefly Describe What The Code Below Does Word 1 (23.41 KiB) Viewed 79 times
Suppose we have a square matrix: int matrix [n] [n], where n>0. Can you briefly describe what the code below does (word
-
- Posts: 43759
- Joined: Sat Aug 07, 2021 7:38 am
Suppose we have a square matrix: int matrix [n] [n], where n>0. Can you briefly describe what the code below does (word
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. 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;