===== С++ 17 =====
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n = 5;
int a[n][n];
srand(time(NULL));
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
a[i][j] = rand() % 199 - 99;
cout << setw(4) << a[i][j] << " ";
}
cout << endl;
// матрица готова к работе
int min = 1000;
if (a[i][n - i - 1] < min)
min = a[i][n - i - 1];
cout << "\nMin = " << min;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
===== С++ 17 =====
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n = 5;
int a[n][n];
srand(time(NULL));
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
a[i][j] = rand() % 199 - 99;
cout << setw(4) << a[i][j] << " ";
}
cout << endl;
}
// матрица готова к работе
int min = 1000;
for(int i = 0; i < n; i++)
if (a[i][n - i - 1] < min)
min = a[i][n - i - 1];
cout << "\nMin = " << min;
return 0;
}