Skip to content

Instantly share code, notes, and snippets.

@xlqstar
Created August 31, 2013 12:38
Show Gist options
  • Save xlqstar/6397938 to your computer and use it in GitHub Desktop.
Save xlqstar/6397938 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
min, max := 0, 100
fmt.Printf("%d--%d", min, max)
for min < max {
i := (min + max) / 2
fmt.Printf("<=%d(y or n) ", i)
var s string
fmt.Scanf("%s", &s)
if s != "" && s[0] == 'y' {
max = i
} else {
min = i + 1
}
}
fmt.Printf("%d\n", max)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment