Hey all! So I am watching online tutorials about C. I found an exercise which asked me to write a code in C which "removes" all rows of a matrix whose first element is divisible by 2. I came up with this.
Code:
for (i = 0 ; i < V ; i++) { /*V = ''height'' of matrix*/
if (matrica[i][0] % 2 == 0) {
for (k = i ; k < V - 1 ; k++) {
for (j = 0 ; j < S ; j++) { /* ''S'' width of matrix*/
matrica[k][j] = matrica[k+1][j];
}
}
i--;
V--;
}
}
So if I had a matrix that looked like this:
1 1 1
2 2 2
3 3 3
4 4 4
After using this code it would look like this:
1 1 1
3 3 3
However, I cannot seem to figure out if I can do something similar to this which works for columns. Can anyone help out?