[FUNC]exchangeSort

arrX:=[8,3,5,7,1,2,3,4,9,6,10,0,12,13,14]
exchangeSort(arrX)

MsgBox %  "排序后:`t" printArr(arrX)"`n"
    . "最大值:`t"getMax(arrX) "`n"
    . "最小值:`t"getMin(arrX) "`n"
return
getMax(arr)
{
  max:=arr[1]
  for key,val in arr
  {
     max:= max<=val ? val:max
  }
  return  max
}


getMin(arr)
{
  min:=arr[1]
  for key,val in arr
  {
     min:= min>=val ? val:min
  }
  return  min
}

exchangeSort(arr)
{
  n:=arr.MaxIndex()
  for i,v in arr
  {
    loop % n-i
    {
      j:=i+A_Index
        if (arr[j]

你可能感兴趣的:(AHK,AutoHotkey)