跳至内容

ArrayMinimum

ArrayMinimum

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

int  ArrayMinimum(
   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    minValueIdx=ArrayMinimum(num_array,WHOLE_ARRAY,0);
   Print("Min value = ",num_array[minValueIdx]," at index=",minValueIdx);
  }

另请参阅

ArrayMaximum()

最后更新于