Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "Russian");
- int rows=20;
- int cols=20;
- cout << "Введите количество строк: ";
- cin >> rows;
- cout << "Введите количество столбцов: ";
- cin >> cols;
- if (int(rows) != int(cols)) {
- cout << "Не квадратная матрица" << endl;
- system("pause");
- return 0;
- }
- int **arr = new int*[rows];
- for (int i = 0; i < rows; i++) {
- arr[i] = new int[cols];
- }
- for (int i = 0; i < rows; i++) {
- for (int j = 0; j < cols; j++) {
- cout << "строка # "<< i+1 << "\t";
- cout << "столбец # "<<j+1 << "= ";
- cin >> arr[i][j];
- }
- }
- for (int i = 0; i < rows; i++) {
- for (int j = 0; j < cols; j++) {
- cout << arr[i][j] << "\t";
- }
- cout << endl;
- }
- for (int i = 0; i < rows; i++)
- {
- delete[] arr[i];
- }
- delete[] arr;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement