It should should shift to the right after deleting an element from the array like on the first picture, but then i always get a wrong output or result as the row 1: column 2 is always 0.
Code:
// Deletion block that moves the remaining elements to the front if (rowPosition >= 0 && rowPosition < row && columnPosition >= 0 && columnPosition < column) { for (int rowIndex = rowPosition; rowIndex < row; rowIndex++) { for (int columnIndex = (rowIndex == rowPosition ? columnPosition : 0); columnIndex < column - 1; columnIndex++) { array[rowIndex][columnIndex] = array[rowIndex][columnIndex + 1]; } array[rowIndex][column - 1] = 0; // Set the last element to 0 } } else { cout << "Invalid position for deletion." << endl; }