!/bin/bash
m=$[RANDOM%5+1]
while :
do
read -p"输入数字1~5 " n;
while :
do
if [ $n -gt $m ] ; then echo "数字猜大了" && break;
elif [ $n -eq $m ] ; then echo "恭喜你 猜对了" &&
read -p"1继续/2退出" instrutc;
if [ $instrutc == 1 ] ;
then echo "你选择再来一次" && m=$[RANDOM%5+1] && break;
else echo "游戏结束 再见" && return;
fi
elif [ $n -lt $m ] ; then echo "数字猜小了" && break;
fi
done
done
linux 猜数字游戏脚本
最新推荐文章于 2024-06-28 09:31:42 发布