guess
This commit is contained in:
29
guess/guess.go
Normal file
29
guess/guess.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func main() {
|
||||
count := 1
|
||||
nok := true
|
||||
search := rand.Intn(100) + 1
|
||||
zahl := 100
|
||||
fmt.Println("rate eine Zahl zwischen 1 und 100")
|
||||
for nok {
|
||||
fmt.Print("Versuch ", count)
|
||||
fmt.Print(" : ")
|
||||
fmt.Scanln(&zahl)
|
||||
if zahl == search {
|
||||
nok = false
|
||||
} else if zahl < search {
|
||||
fmt.Println("Zu klein")
|
||||
count++
|
||||
} else {
|
||||
fmt.Println("Zu groß")
|
||||
count++
|
||||
}
|
||||
}
|
||||
fmt.Println("Du hast die Zahl gefunden!")
|
||||
}
|
||||
Reference in New Issue
Block a user