summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--I_anno/Programmazione_1/ex01.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/I_anno/Programmazione_1/ex01.cc b/I_anno/Programmazione_1/ex01.cc
new file mode 100644
index 0000000..ef91698
--- /dev/null
+++ b/I_anno/Programmazione_1/ex01.cc
@@ -0,0 +1,41 @@
+#include <iostream>
+#include <algorithm>
+#include <vector>
+#define K 2
+#define N 3
+
+using namespace std;
+
+bool func(int a[K][N][N], int w) {
+ vector<int> list;
+ for(int i = 0; i < K; ++i) {
+ list.clear();
+ for(int j = 0; j < N; ++j)
+ list.push_back(a[i][j][j]);
+
+ auto mm = minmax_element(begin(list), end(list));
+ float media = (static_cast<float>(*mm.first)+static_cast<float>(*mm.second))/2;
+ if(media <= w)
+ return true;
+ }
+
+ return false;
+}
+
+int main() {
+ int a[K][N][N] = {
+ {
+ {1, 2, 30},
+ {1, 80, 3},
+ {1, 2, 3},
+ },
+ {
+ {1, 2, 30},
+ {1, 20, 3},
+ {1, 2, 3},
+ }};
+
+ cout << func(a, 5);
+
+ return 0;
+}