/* Динамически выделить матрицу 4х4 типа int. Инициализировать ее псевдослучайными числами через функцию rand. Вывести на экран. Разбейте вашу программу на функции которые вызываются из main. */ #include void PrintArray(int**, const size_t); void FillRandArray(int**, const size_t); int Task_2() { std::cout << "\t\tTask #2" << std::endl; const size_t SIZE = 4U; int** aaInts = new (std::nothrow) int* [SIZE]; if (aaInts != nullptr && SIZE > 0) { for (size_t i = 0; i < SIZE; i++) { aaInts[i] = new int[SIZE]; if (aaInts[i] == nullptr) { std::cerr << "Something wrong with memory allocation in Task #2.\n"; return -1; } } std::cout << "Memory allocation is successful." << std::endl; FillRandArray(aaInts, SIZE); PrintArray(aaInts, SIZE); } else { std::cerr << "Something wrong with memory allocation in Task #2.\n"; return -1; } std::cout << "Allocated memory deletion ...\n"; for (size_t i = 0; i < SIZE; i++) { delete[] aaInts[i]; } delete[] aaInts; std::cout << "________________________________________________\n\n"; system("pause"); system("cls"); return 0; }