/
ArtT
/
Netology
Обзор
Документация
Войти
/
ArtT
/
Netology
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Part1/task_1_10_3.cpp
62 строки
1 KB
ArtT
Навёл порядок
14 ноя 2025, 15:46
14 ноя 2025, 15:46
27cf136
Код
Авторство
О чём код?
#include <iostream> using namespace std; int** create_two_dim_array(const int nRows, const int nCols) { int** arr = new int* [nRows]; for (int i = 0; i < nRows; i ++) { arr[i] = new int[nCols](); } return arr; } void fill_two_dim_array(int ** arr, const int nRows, const int nCols) { for (int i = 0; i < nRows; i ++) { for (int j = 0; j < nCols; j ++) { arr[i][j] = (i + 1)*(j + 1); } } } void print_two_dim_array(int ** arr, const int nRows, const int nCols) { cout << "Таблица умножения: " << endl; for (int i = 0; i < nRows; i ++) { for (int j = 0; j < nCols; j ++) { cout << arr[i][j] << "\t"; } cout << endl; } } void delete_two_dim_array(int ** arr, const int nRows) { for (int i = 0; i < nRows; i ++) delete[] arr[i]; delete[] arr; } int main() { setlocale(LC_CTYPE, "rus"); int nCols{0}, nRows{0}; cout << "Введите количество строк: "; cin >> nRows; cout << "Введите количество столбцов: "; cin >> nCols; int ** arr = create_two_dim_array(nRows, nCols); fill_two_dim_array(arr, nRows, nCols); print_two_dim_array(arr, nRows, nCols); delete_two_dim_array(arr, nRows); return EXIT_SUCCESS; }