package main
import (
"fmt"
)
func BinaryFind(arr *[6]int, leftIndex int, rightIndex int, findValue int) {
if leftIndex > rightIndex {
fmt.Printf("在arr数组未查询到%v", findValue)
return
}
var middle int = (rightIndex + leftIndex) / 2
if arr[middle] > findValue {
BinaryFind(arr, leftIndex, middle - 1, findValue)
} else if arr[middle] < findValue {
BinaryFind(arr, middle + 1, rightIndex, findValue)
} else {
fmt.Printf("在arr数组查询到%v,下标为%v", findValue, middle)
return
}
}
func main() {
var arr [6]int = [6]int{11,22,33,55,66,77}
BinaryFind(&arr, 0, len(arr) - 1, 55)
}