#include <iostream>
#include <windows.h>
#include <format>
using namespace std;
int main()
{
SetConsoleOutputCP(1251);
int const a{ 5 };
int const b{ 6 };
int i{}, j{};
double arithmetic_mean1{}, arithmetic_mean2{}, arithmetic_mean3{}, arithmetic_mean4{}, arithmetic_mean5{}, arithmetic_mean6{}, max1{}, max2{}, max3{}, max4{}, max5{}, min1{}, min2{}, min3{}, min4{}, min5{}, sum1{}, sum2{}, sum3{}, sum4{}, sum5{}, sum6{};
double Z[a][b]{};
srand(time(0));
cout << "Задана матриця: " << endl;
for (i = 0; i < a; i++) {
for (j = 0; j < b; j++) {
Z[i][j] = rand() % 100;
cout << format("{:7}", Z[i][j]);
}
cout << endl;
}
max1 = Z[0][0];
max2 = Z[1][0];
max3 = Z[2][0];
max4 = Z[3][0];
max5 = Z[4][0];
min1 = Z[0][0];
min2 = Z[1][0];
min3 = Z[2][0];
min4 = Z[3][0];
min5 = Z[4][0];
for (i = 0; i < a; i++) {
for (j = 0; j < b; j++) {
if (i == 0) {
if (Z[i][j] > max1) {
max1 = Z[i][j];
}
if (Z[i][j] < min1) {
min1 = Z[i][j];
}
}
if (i == 1) {
if (Z[i][j] > max2) {
max2 = Z[i][j];
}
if (Z[i][j] < min2) {
min2 = Z[i][j];
}
}
if (i == 2) {
if (Z[i][j] > max3) {
max3 = Z[i][j];
}
if (Z[i][j] < min3) {
min3 = Z[i][j];
}
}
if (i == 3) {
if (Z[i][j] > max4) {
max4 = Z[i][j];
}
if (Z[i][j] < min4) {
min4 = Z[i][j];
}
}
if (i == 4) {
if (Z[i][j] > max5) {
max5 = Z[i][j];
}
if (Z[i][j] < min5) {
min5 = Z[i][j];
}
}
if (j == 0) {
sum1 += Z[i][j];
}
if (j == 1) {
sum2 += Z[i][j];
}
if (j == 2) {
sum3 += Z[i][j];
}
if (j == 3) {
sum4 += Z[i][j];
}
if (j == 4) {
sum5 += Z[i][j];
}
if (j == 5) {
sum6 += Z[i][j];
}
}
}
arithmetic_mean1 = sum1 / 5;
arithmetic_mean2 = sum2 / 5;
arithmetic_mean3 = sum3 / 5;
arithmetic_mean4 = sum4 / 5;
arithmetic_mean5 = sum5 / 5;
arithmetic_mean6 = sum6 / 5;
cout << "Максимальний елемент першого рядка - " << max1 << endl;
cout << "Максимальний елемент другого рядка - " << max2 << endl;
cout << "Максимальний елемент третього рядка - " << max3 << endl;
cout << "Максимальний елемент четвертого рядка - " << max4 << endl;
cout << "Максимальний елемент п'ятого рядка - " << max5 << endl;
cout << "Середнє арифметичне першого стовпця - " << arithmetic_mean1 << endl;
cout << "Середнє арифметичне другого стовпця - " << arithmetic_mean2 << endl;
cout << "Середнє арифметичне третього стовпця - " << arithmetic_mean3 << endl;
cout << "Середнє арифметичне четвертого стовпця - " << arithmetic_mean4 << endl;
cout << "Середнє арифметичне п'ятого стовпця - " << arithmetic_mean5 << endl;
cout << "Середнє арифметичне шостого стовпця - " << arithmetic_mean6 << endl;
}