summaryrefslogtreecommitdiff
path: root/1_anno/Programmazione_1/ex1_06_12_18.cc
blob: b16748f5f27dbbb40c7fcd35a746c4fe05d9c77f (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
28
29
30
31
32
33
34
35
#include<iostream>

using namespace std;

template<int N>
bool func(int (&A)[N][N], double w) {
    int sumDiagonale{};
    for(int i = 0; i < N; ++i) sumDiagonale+=A[i][i];

    for(int i = 0; i < N; ++i) {
        int sumCol{};
        for(int j = 0; j < N; ++j) {
            sumCol+=A[j][i];
        }

        if(static_cast<double>(sumCol/sumDiagonale) > w)
            return true;
    }
    

    return false;
}

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

    cout << func(A, 4.5);
    
    return 0;
}