Skip to content

Instantly share code, notes, and snippets.

@skikozou
Created July 25, 2024 11:37
Show Gist options
  • Save skikozou/415ca1517e9835a744fd8ad12287e1af to your computer and use it in GitHub Desktop.
Save skikozou/415ca1517e9835a744fd8ad12287e1af to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math/rand"
"strconv"
)
func main() {
fmt.Println("guessのgoバージョン")
var i string
var in string
var wallet int
wallet = 50000
for {
fmt.Printf("how stakes (コイン)\n>")
fmt.Scan(&in)
stakes, _ := strconv.Atoi(in)
mon, _ := strconv.Atoi(fmt.Sprintf("%.0f", float64(stakes)*0.15))
mon = mon * 10
fmt.Printf("guess number!\n>")
fmt.Scan(&i)
n := strconv.Itoa(rand.Intn(3) + 1)
if n == i {
fmt.Println(mon, "コイン儲かった!")
wallet += mon
} else {
fmt.Println(mon, "コイン損した...")
wallet -= mon
}
fmt.Println(wallet, "コイン")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment