/
MaxAsn111
/
Netologia
Обзор
Документация
Войти
/
MaxAsn111
/
Netologia
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
DynamicMemory
DynamicTable.cpp
55 строк
1 KB
MaxAsn111
create DynamicTable.cpp
22 июн 2025, 14:56
22 июн 2025, 14:56
31d3755
Код
Авторство
О чём код?
#include <iostream> int** create_two_dim_array(int rows, int cols) { int** arr = new int*[rows]; for (int i = 0; i < rows; i++) { arr[i] = new int[cols]; } return arr; } void fill_two_dim_array(int** arr, int rows, int cols) { for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { arr[i][j] = (i + 1) * (j + 1); } } } void print_two_dim_array(int** arr, int rows, int cols) { for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { std::cout << arr[i][j]; if (j != cols - 1) { std::cout << " "; } } std::cout << "\n"; } } void delete_two_dim_array(int** arr, int rows, int cols) { for (int i = 0; i < rows; i++) { delete[] arr[i]; } delete[] arr; } int main() { setlocale(LC_CTYPE, "rus"); int rows, cols; std::cout << "Введите количество строк: "; std::cin >> rows; std::cout << "Введите количество столбцов: "; std::cin >> cols; int** table = create_two_dim_array(rows, cols); fill_two_dim_array(table, rows, cols); std::cout << "Таблица умножения:\n"; print_two_dim_array(table, rows, cols); delete_two_dim_array(table, rows, cols); return 0; }