Заполняется случайными числами, можно сделать пользовательский ввод, заменив arr[i][j] = rand() % 100; на cin >> arr[i][j];
#include <iostream>
#include <random>
#include <ctime>
#include <cmath>
using namespace std;
void printArr(int** arr, size_t sizeX, size_t sizeY) {
for (size_t i = 0; i < sizeX; ++i) {
for (size_t j = 0; j < sizeY; ++j) {
cout << arr[i][j] << " ";
}
cout << endl;
void func1(int** arr, size_t sizeX, size_t sizeY) {
if (arr[i][j] % 2 == 1) {
arr[i][j] *= 2;
void func2(int** arr, size_t sizeX, size_t sizeY) {
int32_t min = INT32_MAX;
if (arr[i][j] < min) {
min = arr[i][j];
cout << i << ": sqrt(" << min << ") = " << sqrt(min) << endl;
int main() {
srand(time(0));
const size_t sizeX = 4, sizeY = 3;
int** arr = new int*[4];
arr[i] = new int[sizeY];
arr[i][j] = rand() % 100;
printArr(arr, sizeX, sizeY);
func1(arr, sizeX, sizeY);
func2(arr, sizeX, sizeY);
Заполняется случайными числами, можно сделать пользовательский ввод, заменив arr[i][j] = rand() % 100; на cin >> arr[i][j];
#include <iostream>
#include <random>
#include <ctime>
#include <cmath>
using namespace std;
void printArr(int** arr, size_t sizeX, size_t sizeY) {
for (size_t i = 0; i < sizeX; ++i) {
for (size_t j = 0; j < sizeY; ++j) {
cout << arr[i][j] << " ";
}
cout << endl;
}
}
void func1(int** arr, size_t sizeX, size_t sizeY) {
for (size_t i = 0; i < sizeX; ++i) {
for (size_t j = 0; j < sizeY; ++j) {
if (arr[i][j] % 2 == 1) {
arr[i][j] *= 2;
}
}
}
}
void func2(int** arr, size_t sizeX, size_t sizeY) {
for (size_t i = 0; i < sizeX; ++i) {
int32_t min = INT32_MAX;
for (size_t j = 0; j < sizeY; ++j) {
if (arr[i][j] < min) {
min = arr[i][j];
}
}
cout << i << ": sqrt(" << min << ") = " << sqrt(min) << endl;
}
}
int main() {
srand(time(0));
const size_t sizeX = 4, sizeY = 3;
int** arr = new int*[4];
for (size_t i = 0; i < sizeX; ++i) {
arr[i] = new int[sizeY];
for (size_t j = 0; j < sizeY; ++j) {
arr[i][j] = rand() % 100;
}
}
printArr(arr, sizeX, sizeY);
func1(arr, sizeX, sizeY);
cout << endl;
printArr(arr, sizeX, sizeY);
func2(arr, sizeX, sizeY);
}