跳至内容

ArrayMaximum

ArrayMaximum

此函数用于在一维数字数组中查找最大元素。

int  ArrayMaximum(
   const void&   array[],             // array for search
   int           count=WHOLE_ARRAY,   // number of checked elements
   int           start=0              // index to start checking with
   );

参数

array[]

[in] 一个数字数组,将在其中进行搜索。

count=WHOLE_ARRAY

[in] 要搜索的元素数量。默认情况下,在整个数组中搜索(count=WHOLE_ARRAY).

start=0

[in] 开始检查的索引。

返回值

该函数返回找到的元素的索引,同时考虑数组serial。如果搜索失败,则返回 -1。

示例:

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);
  }

另请参阅

ArrayMinimum()

最后更新于