A shell's scissors, rock, and cloth games, you can check it out if you like

vim a_ guess rock, scissors, cloth.sh

#!/bin/bash
game=(Rock Paper Scissors)
num= [RANDOM computer = [RANDOM%3] computer=[RANDOMcomputer={game[$sum]}

echo "-------You must enter the number prompted by the system ------"
echo "Please choose the gesture you want according to the following prompts"
echo "1. Scissors"
echo "2. Rock"
echo "3 .Cloth"

read -p “请选择 1 - 3 :” person
case KaTeX parse error: Expected 'EOF', got '#' at position 14: person in 1) #̲!/bin/bash game…[ RANDOM%3 ]
computer=KaTeX parse error: Expected '}', got 'EOF' at end of input: {game[sum]}

echo "-------You must enter the number prompted by the system ------"
echo "Please choose the gesture you want according to the following prompts"
echo "1. Scissors"
echo "2. Rock"
echo "3 .Cloth"

read -p "Please choose 1-3 :" person
case $person in
1)
if [$num -eq 0 ]; then
echo "tie"
elif [$num -eq 1 ]; then
echo "you won"
else
echo "You lost"
fi;;
2)
if [$num -eq 0 ];then
echo "You lost"
elif [$num -eq 1 ];then
echo "tie"
else
echo "You won"
fi;;
3)
if [$num -eq 0 ]; then
echo "you won"
elif [$num -eq 1 ]; then
echo "you lost"
else
echo "tie"
fi;;
*)
echo "must enter 1- The number between 3 "
esac

Then it's OK to run

Guess you like

Origin blog.csdn.net/weixin_52310457/article/details/109642670