package main
import "fmt"
func BinaryFind(arr *[6]int, leftIndex int, rightIndex int, findVal int){
if leftIndex > rightIndex{fmt.Println("没有找到", findVal)
}
middleIndex := (leftIndex + rightIndex) / 2
if (*arr)[middleIndex] > findVal {BinaryFind(arr, leftIndex, middleIndex - 1, findVal)
}else if (*arr)[middleIndex] < findVal{BinaryFind(arr, middleIndex + 1, rightIndex, findVal)
}else{fmt.Printf("找到 %v 了,下标为:%v\n", findVal, middleIndex)
}
}
func main(){
// 有序数组
arr := [6]int{1, 3, 5, 7, 9, 11}
BinaryFind(&arr, 0, len(arr) - 1, 11)
}