This commit is contained in:
2026-03-14 01:04:11 +01:00
parent aab100fd9f
commit 06d6fb22d6
2 changed files with 32 additions and 0 deletions

3
guess/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module guess
go 1.25.0

29
guess/guess.go Normal file
View 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!")
}