#!/bin/bash
PRICE=$(expr $RANDOM % 1000)
TIMES=0
echo "商品实际价格范围为0~999,猜猜是多少?"
while true
do
read -p "请输入你的猜测价格数目:" INT
let TIMES++
# if [ $TIMES = 3 ];then
# echo "不好意思你已经输错三次"
# break
# fi
if [ $INT -eq $PRICE ]; then
echo "恭喜你,猜对了,实际价格是$PRICE"
echo "你总共猜测了$TIMES次"
elif [ $TIMES = 3 ];then
echo "你猜了三次,退出了"
exit 0
elif [ $INT -gt $PRICE ]; then
echo "太高了"
else
echo “太低了”
fi
done
shell_数字游戏
最新推荐文章于 2023-06-20 11:28:04 发布