Given a dynamic two-dimensional array. Delete all lines and columns at the intersection of which is "0". Normally deletes only the lines. Columns are not normal (deletes only from the end, even if the first one contains "0"). Help
#include <iostream> #include <time.h> #include <cstdlib> using namespace std; int** Memory(int col, int row) { int **arr = new int*[row]; for (int i = 0; i < row; i++) { arr[i] = new int[col]; } return arr; } void Rand(int col, int row, int **arr) { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { arr[i][j] = rand() % 20; } } } void RowColDel(int **arr, int row, int col); void main() { setlocale(LC_ALL, "ukr"); srand(time(NULL)); int col = 5; int row = 5; int **arr = Memory(col, row); Rand(col, row, arr); Print(col, row, arr); cout << endl; RowColDel(arr, row, col); //Delete(arr, col, row); } void RowColDel(int **arr, int row, int col) { int row1 = row, col1 = col; int **tmp = Memory(col1, row1); for (int i = 0, i1 = 0; i < row; i++) { bool rows = false; for (int j = 0; j < col; j++) { if (arr[i][j] == 0) { rows = true; break; } else rows = false; } if (rows == false) { tmp[i1] = arr[i]; i1++; } else row1--; } for (int i = 0, i1 = 0; i < col; i++) { bool cols = false; for (int j = 0; j < row; j++) { if (arr[i][j] == 0) { cols = true; break; } else cols = false; } if (cols == false) { tmp[i1] = arr[i]; i1++; } else col1--; } Print(col1, row1, tmp); // Delete(tmp, col1, row1); }