`max = A[0][0];`

should be outside of cycles looking for a maximum. `B[i][j] = A[i + 1][j];`

- Where did B come from?`for (int i = str; i < m-1; i++) {`

for (int j = 0; j <= n; j++)

{

B[i][j] = A[i + 1][j];

}

}

all lines B before str remain uninitialized. In the j loop the condition is wrong, it should be `j < n`

In the last cycle. `for (int i = 0; i < m; i++)`

Wrong, it should be `i < m - 1`

`k`

should be removed from the code and replaced with `m - 1`