Created
August 31, 2013 12:38
-
-
Save xlqstar/6397938 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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