#include <iostream>

using namespace std;

int main(){
	int rovs, cols;
	// ввод размера матрицы пока размер не будет больше 0
	while (true){
		cout << "Input rovs of matrix: " << endl;
		cin >> rovs;

		cout << "Input cols of matrix: " << endl;
		cin >> cols;

		if ((rovs < 1) || (cols < 1)){
			cout << "The size of matrix can't be less than 1." << endl;
			cout << "-------------" << endl;
		}
		else {
			cout << "-------------" << endl;
			break;
		}
	}

	int **matrix = new int *[rovs];
	for (int i = 0; i < rovs; i++){
		matrix[i] = new int [cols];
	}

	int **result_matrix = new int *[rovs];
	for (int i = 0; i < rovs; i++){
		result_matrix[i] = new int [cols];
	}

	cout << "Input matrix's elements: " << endl;
    for (int i = 0; i < rovs; i++){
		for (int j = 0; j < cols; j++){
            cin >> matrix[i][j];
        }
	}

	cout << "-------------" << endl;

	for (int i = 0; i < rovs; i++){
		for (int j = 0; j < cols; j++){
			cout << matrix[i][j] << "\t";
        }
		cout << endl;
	}

	cout << "-------------" << endl;

	// заполнение изменённой матрицы
	for (int i = 0; i < rovs; i++){
		for (int j = 0; j < cols; j++){
			result_matrix[i][j] = matrix[i][j];
			if (i + j == (rovs - 1)){
				result_matrix[i][j] = 100;
			}
		}
    }

	// вывод изменённой матрицы
	for (int i = 0; i < rovs; i++){
		for (int j = 0; j < cols; j++){
			cout << result_matrix[i][j] << "\t";
        }
		cout << endl;
	}

	for (int i = 0; i < rovs; i++){
		delete[] matrix[i];
		delete[] result_matrix[i];
	}

	delete[] matrix;
	delete[] result_matrix;
    
	return 0;
}
