Answer the question
In order to leave comments, you need to log in
How to remove a row from a matrix?
It is necessary to remove from the matrix 6 * 7 the row containing the maximum element.
Here is a code snippet:
#define m 7
#define n 6
#define k 6
.....
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
max = A[0][0];
if (max < A[i][j])
{
max = A[i][j];
str = i;
}
}
}
for (int i = str; i < m-1; i++) {
for (int j = 0; j < k; j++)
{
B[i][j] = A[i + 1][j];
}
}
Answer the question
In order to leave comments, you need to log in
max = A[0][0];
must be outside the cycles seeking the maximum.
B[i][j] = A[i + 1][j];
- where did B come from?
In full code:
for (int i = str; i < m-1; i++) {
for (int j = 0; j <= n; j++)
{
B[i][j] = A[i + 1][j];
}
}
j < n
for (int i = 0; i < m; i++)
i < m - 1
k
thrown out of the code and replaced withm - 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question