summaryrefslogtreecommitdiff
path: root/I_anno/Programmazione_1/ex13.cc
diff options
context:
space:
mode:
authorSanto Cariotti <dcariotti24@gmail.com>2020-10-18 18:56:43 +0200
committerSanto Cariotti <dcariotti24@gmail.com>2020-10-20 09:08:52 +0200
commitf279107065146a4940f5e73602a1c3c09e58b31d (patch)
treefd892749637a8b6c5c31ccb80bba04ade76ab87a /I_anno/Programmazione_1/ex13.cc
parent4e063e32250312c38d5646840719b62429362b21 (diff)
chore: name of first year folder
Diffstat (limited to 'I_anno/Programmazione_1/ex13.cc')
-rw-r--r--I_anno/Programmazione_1/ex13.cc45
1 files changed, 0 insertions, 45 deletions
diff --git a/I_anno/Programmazione_1/ex13.cc b/I_anno/Programmazione_1/ex13.cc
deleted file mode 100644
index f9f19fa..0000000
--- a/I_anno/Programmazione_1/ex13.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <iostream>
-#include <memory>
-#include <algorithm>
-#include <vector>
-using namespace std;
-
-template<int N, int K>
-unique_ptr<double[]> func(int (&A)[K][N], int (&B)[N][K]) {
- auto arr = unique_ptr<double[]>(new double{K});
- for(int i = 0; i < K; ++i) {
- vector<int> t;
- int sum = 0;
- for(int j = 0; j < N; ++j) {
- t.push_back(B[j][i]);
- sum+=A[i][j];
- }
-
- double media = static_cast<double>(sum)/N;
- auto min_num = min_element(begin(t), end(t));
- arr[i] = media - *min_num;
- }
-
- return arr;
-}
-
-int main() {
- const int N2 = 3, K2 = 2;
- int A[K2][N2] = {
- {3, 7, 10},
- {5, 12, 32},
- };
- int B[N2][K2] = {
- {12, 10},
- {15, 17},
- {8, 0},
- };
- auto x = func(A, B);
-
- for(int i = 0; i < K2; ++i)
- cout << x[i] << ' ';
-
- cout << endl;
-
- return 0;
-}