summaryrefslogtreecommitdiff
path: root/I_anno/Programmazione_1/ex1_tutorato_14_01_20.cc
blob: 557b0eede91bc8b6d4a11c7aa00fcebd17ac290c (plain)
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
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

template<int N>
bool func(int (&A)[N][N], double w) {
    vector<int> list;
    for(int i = 0, j = N-1; i < N; ++i, --j) 
        list.push_back(A[j][i]);

    auto minmax = minmax_element(begin(list), end(list));
    return (static_cast<double>(*minmax.first)/static_cast<double>(*minmax.second)) <= w;
}

int main() {
    int A[3][3] = {
        {1, 2, 3},
        {1, 2, 3},
        {1, 2, 3},
    };

    cout << func(A, 0.1);

    return 0;
}