0
Как создать функцию который будет находит минимум элемента в матрице(i need to make a function who search a min in double array)
на каком языке вам вопрос? have someone who understand russian?
5 Respostas
+ 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
+ 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;
}
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];
0
sorry i need a array like this : array [ ] [ ]
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];