mironion Posted November 8, 2018 Report Posted November 8, 2018 Un program ce calculeaza suma si numarul elementelor pozitive din coloane pare. 1 Quote
spider Posted November 8, 2018 Report Posted November 8, 2018 1 hour ago, mironion said: Un program ce calculeaza suma si numarul elementelor pozitive din coloane pare. Quote
u0m3 Posted November 8, 2018 Report Posted November 8, 2018 (edited) 4 hours ago, mironion said: Un program ce calculeaza suma si numarul elementelor pozitive din coloane pare. Acesta este un forum, nu "ghiseul" unde plasezi comanda la McDonald's... Exprima si tu, in cuvinte, preferabil si cat de cat coerent, ce doresti. Acesta este un forum, nu fabrica de facut teme, nu e colegu' de clasa pe care il ameniti ca il bati daca nu iti face tema. Nu te astepta sa ne scrii enuntul problemei si noi sa ti-o rezolvam; arata si tu ca ti-ai dat un minim interes... Edited November 8, 2018 by u0m3 6 Quote
mironion Posted November 10, 2018 Author Report Posted November 10, 2018 On 11/8/2018 at 11:55 PM, u0m3 said: Acesta este un forum, nu "ghiseul" unde plasezi comanda la McDonald's... Exprima si tu, in cuvinte, preferabil si cat de cat coerent, ce doresti. Acesta este un forum, nu fabrica de facut teme, nu e colegu' de clasa pe care il ameniti ca il bati daca nu iti face tema. Nu te astepta sa ne scrii enuntul problemei si noi sa ti-o rezolvam; arata si tu ca ti-ai dat un minim interes... Mdaa.Mai ajutat foarte mult! Îți mulțumesc 2 Quote
u0m3 Posted November 11, 2018 Report Posted November 11, 2018 (edited) #define E_ASSIGNMENT_OK 0 #define E_ASSIGNMENT_INVALID_MATRIX_DIMENSIONS -1 #define E_ASSIGNMENT_INVALID_RESULT_POINTER -2 struct result_holder { float sum_0based_index; float sum_1based_index; unsigned int count_0based_index; unsigned int count_1based_index; }; int assignment(float const * const matrix, unsigned int const num_rows, unsigned int const num_cols, result_holder * const result) { unsigned int idx = 0 if(num_cols <= 0 || num_rows <= 0) return E_INVALID_MATRIX_DIMENSIONS; if(result_holder == NULL) return E_INVALID_RESULT_POINTER; result.sum_0based_index = 0; result.sum_1based_index = 0; result.count_0based_index = 0; result.count_1based_index = 0; for(unsigned int row = 0; row < num_rows; ++row) { for(unsigned int col = 0; col < num_cols; ++col) { idx = row * num_cols + col; if(col % 2 == 0 && matrix[idx] > 0) { result.sum_0based_index += matrix[idx]; ++result.count_0based_index; } else { result.sum_1based_index += matrix[idx]; ++result.count_1based_index; } } } return E_OK; } Edited November 11, 2018 by u0m3 Quote
u0m3 Posted November 11, 2018 Report Posted November 11, 2018 8 hours ago, mironion said: Mdaa.Mai ajutat foarte mult! Îți mulțumesc Cu placere! Si vezi ca e "M-ai ajutat foarte mult". Acum serios, eu pot sa iti dau si mura-n gura, dar nu vei invata nimic asa... Spoiler #define E_ASSIGNMENT_OK 0 #define E_ASSIGNMENT_INVALID_MATRIX_DIMENSIONS -1 #define E_ASSIGNMENT_INVALID_RESULT_POINTER -2 struct result_holder { float sum_0based_index; float sum_1based_index; unsigned int count_0based_index; unsigned int count_1based_index; }; int assignment(float const * const matrix, unsigned int const num_rows, unsigned int const num_cols, result_holder * const result) { unsigned int idx = 0 if(num_cols <= 0 || num_rows <= 0) return E_INVALID_MATRIX_DIMENSIONS; if(result_holder == NULL) return E_INVALID_RESULT_POINTER; result.sum_0based_index = 0; result.sum_1based_index = 0; result.count_0based_index = 0; result.count_1based_index = 0; for(unsigned int row = 0; row < num_rows; ++row) { for(unsigned int col = 0; col < num_cols; ++col) { idx = row * num_cols + col; if(col % 2 == 0 && matrix[idx] > 0) { result.sum_0based_index += matrix[idx]; ++result.count_0based_index; } else { result.sum_1based_index += matrix[idx]; ++result.count_1based_index; } } } return E_OK; } 1 Quote
mironion Posted November 11, 2018 Author Report Posted November 11, 2018 19 hours ago, u0m3 said: Cu placere! Si vezi ca e "M-ai ajutat foarte mult". Acum serios, eu pot sa iti dau si mura-n gura, dar nu vei invata nimic asa... Reveal hidden contents #define E_ASSIGNMENT_OK 0 #define E_ASSIGNMENT_INVALID_MATRIX_DIMENSIONS -1 #define E_ASSIGNMENT_INVALID_RESULT_POINTER -2 struct result_holder { float sum_0based_index; float sum_1based_index; unsigned int count_0based_index; unsigned int count_1based_index; }; int assignment(float const * const matrix, unsigned int const num_rows, unsigned int const num_cols, result_holder * const result) { unsigned int idx = 0 if(num_cols <= 0 || num_rows <= 0) return E_INVALID_MATRIX_DIMENSIONS; if(result_holder == NULL) return E_INVALID_RESULT_POINTER; result.sum_0based_index = 0; result.sum_1based_index = 0; result.count_0based_index = 0; result.count_1based_index = 0; for(unsigned int row = 0; row < num_rows; ++row) { for(unsigned int col = 0; col < num_cols; ++col) { idx = row * num_cols + col; if(col % 2 == 0 && matrix[idx] > 0) { result.sum_0based_index += matrix[idx]; ++result.count_0based_index; } else { result.sum_1based_index += matrix[idx]; ++result.count_1based_index; } } } return E_OK; } Iti multumesc! eu daca sincer mi-am facut prima parte asta e a2-a care am intrebat Quote