/
monahov
/
learningcplusplus
Обзор
Документация
Войти
/
monahov
/
learningcplusplus
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Lesson 10.3.cpp
62 строки
1 KB
monahov
upload files
27 авг 2025, 20:08
27 авг 2025, 20:08
c59343c
Код
Авторство
О чём код?
#include <iostream> int** create_to_dim_array(int row, int col); void fill_two_dim_array(int** matrix, int row, int col); void print_two_dim_array(int** matrix, int row, int col); void delete_two_dim_array(int** matrix, int row, int col); int main() { setlocale(LC_ALL, "rus"); int row{}, col{}; std::cout << "Введите количество строк: "; std::cin >> row; std::cout << "Введите количество столбцов: "; std::cin >> col; std::cout << "Таблица умножения: "; std::cout << std::endl; int** matrix = create_to_dim_array(row, col); fill_two_dim_array(matrix, row, col); print_two_dim_array(matrix, row, col); delete_two_dim_array(matrix, row, col); return EXIT_SUCCESS; } int** create_to_dim_array(int row, int col) { int** arr = new int*[row]; for (int i{}; i < row; ++i) { arr[i] = new int[col]; } return arr; } void fill_two_dim_array(int** matrix, int row, int col) { for (int i{}; i < row; ++i) { for (int j{}; j < col; ++j) { matrix[i][j] = (i + 1) * (j + 1); } } } void print_two_dim_array(int** matrix, int row, int col) { for (int i{}; i < row; ++i) { for (int j{}; j < col; ++j) { std::cout << matrix[i][j] << "\t"; } std::cout << std::endl; } } void delete_two_dim_array(int** matrix, int row, int col) { for (int i{}; i < row; ++i) { delete[]matrix[i]; } delete[]matrix; }