From 6c6328375c55683645146909b7ab760d0de0d463 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 18 Oct 2020 18:56:43 +0200 Subject: chore: name of first year folder --- 1_anno/Programmazione_1/ex08.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 1_anno/Programmazione_1/ex08.cc (limited to '1_anno/Programmazione_1/ex08.cc') diff --git a/1_anno/Programmazione_1/ex08.cc b/1_anno/Programmazione_1/ex08.cc new file mode 100644 index 0000000..fdfea92 --- /dev/null +++ b/1_anno/Programmazione_1/ex08.cc @@ -0,0 +1,36 @@ +#include +#include +#define N 3 +#define M 5 + +using namespace std; + +bool func(int A[N][M], short k, short w) { + short counter = 0; + for(int i = 0; i < M; ++i) { + short t_counter = 0; + for(int j = 1; j < N; ++j) { + if(A[j][i] < A[j-1][i]) + break; + else + ++t_counter; + } + + if(t_counter >= k) + ++counter; + } + + return counter >= w; +} + +int main() { + int array[N][M] = { + {5, 7, 9, 10, 5}, + {10, 2, 3, 4, 10}, + {16, 34, 21, 23, 1} + }; + + cout << func(array, 2, 1) << endl; + + return 0; +} -- cgit v1.2.3-18-g5258