56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
#include <labs.h>
|
|
|
|
constexpr size_t LEN = 5;
|
|
|
|
void lab5()
|
|
{
|
|
int arr[LEN][LEN], d_min, d_max, d_count, v_max_i, v_max_j;
|
|
|
|
cout << "Enter range min: ";
|
|
cin >> d_min;
|
|
|
|
cout << "Enter range max: ";
|
|
cin >> d_max;
|
|
|
|
for (size_t i = 0; i < LEN; i++)
|
|
for (size_t j = 0; j < LEN; j++)
|
|
{
|
|
cout << "Enter arr[" << i << "][" << j << "]: ";
|
|
cin >> arr[i][j];
|
|
}
|
|
|
|
v_max_i = v_max_j = 0;
|
|
|
|
d_count = 0;
|
|
|
|
for (size_t i = 0; i < LEN; i++)
|
|
for (size_t j = 0; j < LEN; j++)
|
|
{
|
|
if (d_min <= arr[i][j] && arr[i][j] <= d_max)
|
|
d_count++;
|
|
|
|
if (arr[i][j] > arr[v_max_i][v_max_j])
|
|
{
|
|
v_max_i = i;
|
|
v_max_j = j;
|
|
}
|
|
}
|
|
|
|
cout << "Matrix is {" << endl;
|
|
for (size_t i = 0; i < LEN; i++)
|
|
{
|
|
|
|
for (size_t j = 0; j < LEN; j++)
|
|
{
|
|
|
|
cout << '\t' << arr[i][j];
|
|
|
|
if (j < LEN - 1)
|
|
cout << ",";
|
|
}
|
|
cout << endl;
|
|
}
|
|
cout << "}" << endl;
|
|
cout << "Number of elements in range [" << d_min << "; " << d_max << "] is " << d_count << endl;
|
|
cout << "Highest element in array is arr[" << v_max_i << "][" << v_max_j << "] = " << arr[v_max_i][v_max_j] << endl;
|
|
} |