C/C++

Написать код. Использовать функции

 #include  
#include
#include

using namespace std;

size_t input(const char* msg) {
size_t value = 0;
while (!value) {
cout > value;
cin.ignore(0x1000, '\n');
}
return value;
}

int** create(const size_t n, const size_t m, int a, int b) {
auto matrix = new(nothrow) int* [n];
if (matrix == nullptr) return nullptr;
for (size_t i = 0; i < n; ++i) {
matrix[i] = new(nothrow) int[m];
if (matrix[i] == nullptr) {
for (size_t j = 0; j < i; ++j) delete[] matrix[j];
delete[] matrix;
matrix = nullptr;
break;
}
}
if (matrix == nullptr) return nullptr;
if (a > b) swap(a, b);
uniform_int_distribution uid(a, b);
mt19937 gen{ random_device()() };
for (size_t i = 0; i < n; ++i) {
for (size_t j = 0; j < m; ++j) {
matrix[i][j] = uid(gen);
}
}
return matrix;
}

int** destroy(int** matrix, const size_t n) {
if (matrix != nullptr) {
for (size_t i = 0; i < n; ++i) delete[] matrix[i];
delete[] matrix;
matrix = nullptr;
}
return matrix;
}

void show(int** matrix, const size_t n, const size_t m, const streamsize w) {
for (size_t i = 0; i < n; ++i) {
for (size_t j = 0; j < m; ++j) cout
Ар
Арунов
98 398
Лучший ответ
Женя Павлович Как то попроще бы, я только начинающий