ArrayMaximum
ArrayMaximum
The function searches a maximal element in a one-dimension numeric array.
int ArrayMaximum(
const void& array[], // array for search
int count=WHOLE_ARRAY, // number of checked elements
int start=0 // index to start checking with
);Parameters
- array[]
[in] A numeric array, in which search is made.
- count=WHOLE_ARRAY
[in] Number of elements for search. By default, searches in the entire array (count=WHOLE_ARRAY).
- start=0
[in] Index to start checking with.
Return Value
The function returns an index of a found element taking into account the array serial. In case of failure it returns -1.
Example:
void OnStart()
{
//---
double num_array[15]={4,1,6,3,19,4,2,6,3,9,4,5,6,3,9};
int maxValueIdx=ArrayMaximum(num_array,WHOLE_ARRAY,0);
Print("Max value = ",num_array[maxValueIdx]," at index=",maxValueIdx);
}See also
Last updated on