0

Как создать функцию который будет находит минимум элемента в матрице(i need to make a function who search a min in double array)

на каком языке вам вопрос? have someone who understand russian?

6th Feb 2017, 3:58 AM
NO NAME
NO NAME - avatar
5 Respuestas
+ 1
From what I understand is that you need a function that will return the smallest value in a double array, I used vectors because they are much easier to use, and made this so simple, here is the link: https://code.sololearn.com/c6R6tC15fYx7/#cpp
6th Feb 2017, 4:54 AM
Dawzy
Dawzy - avatar
+ 1
Как-то так double minArr(double** arr, size_t size) { double amin = **arr; for(int i = 0; i < size; ++i) for(int j = 0; j < size; ++j) amin = min(arr[i][j], amin); return amin; }
23rd Mar 2017, 3:43 PM
SUPER_S
SUPER_S - avatar
0
Just do a variable minimum, and initializes it with a number of the array, after create a loop to look in the array values, if the value are smaller than the value in minimum variable, equals it. example: double minimum = arr[0]; for(unsigned short int temporaryVar = 0; temporaryVar < 10; temporaryVar++) if(arr[temporaryVar] < minimum) minimum = arr[temporaryVar];
6th Feb 2017, 4:43 AM
João Victor Oliveira Couto
João Victor Oliveira Couto - avatar
0
sorry i need a array like this : array [ ] [ ]
6th Feb 2017, 5:13 AM
NO NAME
NO NAME - avatar
0
so, acrescent one for in the previous code I sended, will be like this: double minimum = arr[0][0]; for(unsigned short int temporary_2 = 0; temporary_2 < 10; temporary_2++) for(unsigned short int temporaryVar = 0; temporaryVar < 10; temporaryVar++) if(arr[temporaryVar][temporary_2] < minimum) minimum = arr[temporaryVar][temporary_2];
6th Feb 2017, 5:19 AM
João Victor Oliveira Couto
João Victor Oliveira Couto - avatar