forked from vitalWord/interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.cpp
More file actions
33 lines (27 loc) · 967 Bytes
/
2.cpp
File metadata and controls
33 lines (27 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Квадратная матрица разделена диагоналями на четыре сектора.
// Напишите функцию min_from_top_sector(), которая будет
// находить значение ячейки, минимальное для всех ячеек верхнего
// сектора, включая отрезки диагоналей, составляющие этот сектор.
#include <iostream>
const int c_kM = 5;
typedef int Matrix[c_kM][c_kM];
int min_from_top_sector(Matrix& m)
{
int temp = m[0][0];
for(int i=0; i<=c_kM/2; i++)
for(int j=i;j<c_kM-i;j++)
if(temp > m[i][j]) temp=m[i][j];
return temp;
}
int _tmain(int argc, _TCHAR* argv[])
{
Matrix matrix;
for(int i=0; i<c_kM; i++)
for(int j=0;j<c_kM;j++)
{
std::cout << std::endl << "m[" <<i+1 <<"]["<<j+1<<"]=";
std::cin >> matrix[i][j];
}
std::cout << min_from_top_sector(matrix) << std::endl;
return 0;
}