1)
#include <iostream>
#include <time.h>
using namespace std;
int** input_array_auto(int** mat, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
mat[i][j] = rand() % 200 - 100;
}
return mat;
int** input_array(int** mat, int n, int m) {
cin >> mat[i][j];
void print_array(int** mat, int n, int m) {
printf("%4.0d", mat[i][j]);
cout << endl;
void swap_first_and_second(int** mat, int n, int m) {
for (size_t i = 0; i < m; i++) {
swap(mat[i][0], mat[i][n - 1]);
int main()
{
setlocale(LC_ALL, "Russian");
srand(time(NULL));
int n, m;
cout << "Введите количество строк: ";
cin >> n;
cout << "Введите количество столбцов: ";
cin >> m;
int** array = new int* [n];
array[i] = new int[m];
array = input_array_auto(array, n, m);
print_array(array, n, m);
swap_first_and_second(array, n, m);
delete[] array;
2)
cout << mat[i][j] << " ";
int* find_max_value_by_cols_to_array(int** mat, int n, int m) {
int* max = new int[m];
int max1;
int max1 = -100;
if (mat[i][j] > max1) {
max1 = mat[i][j];
cout << "Максимум в " << j << " столбце равно: " << max1 << endl;
max[j] = max1;
return max;
long pow_maximums(int* max, int m) {
long max_long_int = 1;
max_long_int *= max[i];
return max_long_int;
int n = 5, m = 5;
long pow_maximum = pow_maximums(find_max_value_by_cols_to_array(array, n, m), m);
cout << "Перемножение максимумов равно: " << pow_maximum;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
1)
#include <iostream>
#include <time.h>
using namespace std;
int** input_array_auto(int** mat, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
mat[i][j] = rand() % 200 - 100;
}
}
return mat;
}
int** input_array(int** mat, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
cin >> mat[i][j];
}
}
return mat;
}
void print_array(int** mat, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
printf("%4.0d", mat[i][j]);
}
cout << endl;
}
cout << endl;
}
void swap_first_and_second(int** mat, int n, int m) {
for (size_t i = 0; i < m; i++) {
swap(mat[i][0], mat[i][n - 1]);
}
}
int main()
{
setlocale(LC_ALL, "Russian");
srand(time(NULL));
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 = input_array_auto(array, n, m);
print_array(array, n, m);
swap_first_and_second(array, n, m);
print_array(array, n, m);
delete[] array;
}
2)
#include <iostream>
#include <time.h>
using namespace std;
int** input_array_auto(int** mat, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
mat[i][j] = rand() % 200 - 100;
}
}
return mat;
}
int** input_array(int** mat, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
cin >> mat[i][j];
}
}
return mat;
}
void print_array(int** mat, int n, int m) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
cout << mat[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
int* find_max_value_by_cols_to_array(int** mat, int n, int m) {
int* max = new int[m];
int max1;
for (size_t j = 0; j < m; j++) {
int max1 = -100;
for (size_t i = 0; i < n; i++) {
if (mat[i][j] > max1) {
max1 = mat[i][j];
}
}
cout << "Максимум в " << j << " столбце равно: " << max1 << endl;
max[j] = max1;
}
return max;
}
long pow_maximums(int* max, int m) {
long max_long_int = 1;
for (size_t i = 0; i < m; i++) {
max_long_int *= max[i];
}
return max_long_int;
}
int main()
{
setlocale(LC_ALL, "Russian");
srand(time(NULL));
int n = 5, m = 5;
int** array = new int* [n];
for (size_t i = 0; i < n; i++) {
array[i] = new int[m];
}
array = input_array_auto(array, n, m);
print_array(array, n, m);
long pow_maximum = pow_maximums(find_max_value_by_cols_to_array(array, n, m), m);
cout << "Перемножение максимумов равно: " << pow_maximum;
}