/
mando
/
DZ10_3
Обзор
Документация
Войти
/
mando
/
DZ10_3
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Source.cpp
67 строк
1 KB
mando
DZ10_3
05 фев 2026, 12:45
Верифицирован
05 фев 2026, 12:45
d311cc4
Код
Авторство
О чём код?
#include <iostream> #include <iomanip> int** create_two_dim_array(int rows, int cols) { int** arr = new int* [rows]; int i = 0; while (i < rows) { arr[i] = new int[cols]; i++; } return arr; } void fill_two_dim_array(int** arr, int rows, int cols) { int i = 0; while (i < rows) { int j = 0; while (j < cols) { arr[i][j] = (i + 1) * (j + 1); j++; } i++; } } void print_two_dim_array(int** arr, int rows, int cols) { int i = 0; while (i < rows) { int j = 0; while (j < cols) { std::cout << std::setw(4) << arr[i][j]; j++; } std::cout << std::endl; i++; } } void delete_two_dim_array(int** arr, int rows) { int i = 0; while (i < rows) { delete[] arr[i]; i++; } delete[] arr; } int main() { setlocale(LC_ALL, "Russian"); int rows, cols; std::cout << "������� ���������� �����: "; std::cin >> rows; std::cout << "������� ���������� ��������: "; std::cin >> cols; int** myTable = create_two_dim_array(rows, cols); fill_two_dim_array(myTable, rows, cols); std::cout << "������� ���������:" << std::endl; print_two_dim_array(myTable, rows, cols); delete_two_dim_array(myTable, rows); return 0; }