#include <iostream>
#include <time.h>
using namespace std;
void print_array(int** arr, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
cout << arr[i][j] << " ";
}
cout << endl;
int** auto_input_matrix(int** arr, int n, int m) {
arr[i][j] = rand() % 200 - 100;
return arr;
int** search_for_the_minimum_and_maximum_values_and_putting_them_at_the_end_of_the_matrix(int** arr, int n, int m) {
int min = 100;
int max = -100;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (arr[i][j] <= min) {
min = arr[i][j];
if (arr[i][j] >= max) {
max = arr[i][j];
arr[i][m-1] = max;
arr[i][0] = min;
min = 100;
max = -100;
int main() {
srand(time(NULL));
setlocale(LC_ALL, "Russian");
int n, m;
cout << "Введите количество строк в массиве: ";
cin >> n;
cout << "Введите количество элементов в массиве построчно: ";
cin >> m;
int** array = new int* [n];
array[i] = new int[m];
array = auto_input_matrix(array, n, m);
print_array(array, n, m);
array = search_for_the_minimum_and_maximum_values_and_putting_them_at_the_end_of_the_matrix(array, n, m);
delete[] array;
#include <iostream>
#include <time.h>
using namespace std;
void print_array(int** arr, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
cout << arr[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
int** auto_input_matrix(int** arr, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
arr[i][j] = rand() % 200 - 100;
}
}
return arr;
}
int** search_for_the_minimum_and_maximum_values_and_putting_them_at_the_end_of_the_matrix(int** arr, int n, int m) {
int min = 100;
int max = -100;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (arr[i][j] <= min) {
min = arr[i][j];
}
if (arr[i][j] >= max) {
max = arr[i][j];
}
}
arr[i][m-1] = max;
arr[i][0] = min;
min = 100;
max = -100;
}
return arr;
}
int main() {
srand(time(NULL));
setlocale(LC_ALL, "Russian");
int n, m;
cout << "Введите количество строк в массиве: ";
cin >> n;
cout << "Введите количество элементов в массиве построчно: ";
cin >> m;
int** array = new int* [n];
for (size_t i = 0; i < n; i++) {
array[i] = new int[m];
}
array = auto_input_matrix(array, n, m);
print_array(array, n, m);
array = search_for_the_minimum_and_maximum_values_and_putting_them_at_the_end_of_the_matrix(array, n, m);
print_array(array, n, m);
delete[] array;
}