From d2edbc38cac8da52f58c5cd3da6c0c625fa05736 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sat, 6 Feb 2021 19:56:36 +0100 Subject: conf: rename --- 1_anno/Programmazione_1/ex1_27_01_20.cc | 47 --------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 1_anno/Programmazione_1/ex1_27_01_20.cc (limited to '1_anno/Programmazione_1/ex1_27_01_20.cc') diff --git a/1_anno/Programmazione_1/ex1_27_01_20.cc b/1_anno/Programmazione_1/ex1_27_01_20.cc deleted file mode 100644 index 1b0e529..0000000 --- a/1_anno/Programmazione_1/ex1_27_01_20.cc +++ /dev/null @@ -1,47 +0,0 @@ -#include -#define N 3 -#define M 4 -using namespace std; - -float* func(int** Q, float a, float b) { - float* arr = new float[M]; - - int a_i = static_cast(a); - int b_i = static_cast(b); - - for(int i = 0; i < M; ++i) { - short counter{}; - float sum{}; - for(int j = 0; j < N; ++j) { - if(Q[j][i]) { - if(Q[j][i] >= a_i && Q[j][i] <= b_i) { - ++counter; - sum += Q[j][i]; - } - } - } - - arr[i] = (sum / static_cast(counter)); - } - - return arr; -} - -int main() { - int** A = new int*[N]; - for(int i = 0; i < N; ++i) { - A[i] = new int[M]; - for(int j = 0; j < M; ++j) - A[i][j] = 24; - } - - float* arr = func(A, 1.0, 33.0); - - for(int j = 0; j < M; ++j) - cout << arr[j] << ' '; - - delete[] A; - delete arr; - - return 0; -} -- cgit v1.2.3-18-g5258