循环5次的猜拳游戏
!/bin/bashj=1
while [ $j -le 5 ]
do
echo "1.石头 2.剪刀 3.布 "
read -p "请出拳1-3:" i
game=(石头 剪刀 布) #//数组
num=$[RANDOM%3] 0-2随即数
echo computer=${game[$num]}
#//数组中第$num个数
case $i in
1)
if [ 0 -eq $num ];then
echo "平局"
elif [ 1 -eq $num ];then
echo "你输了"
else
echo "你赢了"
fi;;
2)
if [ 1 -eq $num ];then
echo "平局"
elif [ 0 -eq $num ];then
echo "你输了"
else
echo "你赢了"
fi;;
3)
if [ 2 -eq $num ];then
echo "平局"
elif [ 1 -eq $num ];then
echo "你输了"
else
echo "你赢了"
fi;;
esac
let j++
done