Uploaded by vlad 27

Matrix

advertisement
#include <cstdlib>
#include <ctime>
#include <stdio.h>
#include <iostream>
#include <stdio.h>
using namespace std;
void sum(int numb)
{
int max_1 = 0;
int max_2 = 0;
std::cout << "Введите нижнюю границу диапазона ";
int r_min;
cin >> r_min;
cout << "\nВведите верхнюю границу диапазона ";
int r_max;
cin >> r_max;
cout << "\nВведите число строк ";
int n;
cin >> n;
cout << "\nВведите число столбцов ";
int m; cin >> m;
m = m;
int mas[n][m];
for (int i=0; i<n; i++)
{
cout << endl;
for(int j=0; j<m; j++)
{
mas [i][j] = rand() % (r_max - r_min+1) + r_min;
cout << mas[i][j]<<" ";
}
max_1 = mas[0][0];
for (int i = 0; i < n; i++)
if (mas[i][i] > max_1)
max_1 = mas[i][i];
max_2 = mas[0][m-1];
for(int i = 0; i < n; i++)
if (mas[i][m-i-1] > max_2)
max_2 = mas[i][m-i-1];
int k;
k = max_1 + max_2;
cout << k << endl;
}
}
int main()
{
int digit;
sum (digit);
return 0;
}
Download