package main
import (
"bufio"
"fmt"
"math/rand"
"os"
"strings"
"time"
)
func rock_paper_scissors(player_choice string) {
choices := []string{"石头", "剪刀", "布"}
rand.Seed(time.Now().UnixNano())
computer_choice := choices[rand.Intn(3)]
fmt.Println("电脑选择: ", computer_choice)
if player_choice == computer_choice {
fmt.Println("平局!")
} else if (player_choice == "石头" && computer_choice == "剪刀") || (player_choice == "剪刀" && computer_choice == "布") || (player_choice == "布" && computer_choice == "石头") {
fmt.Println("你赢了!")
} else {
fmt.Println("你输了!")
}
}
func main() {
fmt.Print("选择石头、剪刀或布:")
user_choice, _ := bufio.NewReader(os.Stdin).ReadString('\n')
user_choice = strings.TrimSpace(user_choice)
rock_paper_scissors(user_choice)
}