猜数小游戏脚本


#!/bin/bash

pc=$(expr $RANDOM % 1000 + 1)
echo "$pc" >> /tmp/123               bug 保存到一个目录下查看答案
cishu=0
echo "这是猜商品的价格的小游戏,价格范围(1-1000)"

while true
do
        read -p "请输入你猜测的价格:" jiage
        let cishu++
        if [ $jiage -eq $pc ]
        then
                echo "恭喜你猜对了,价格就是$jiage "
                echo "共猜了$cishu "
                exit 0
        elif [ $jiage -gt $pc ]
        then
                echo "猜高了"
        else
                echo "猜低了"
         fi
done
~          

猜你喜欢

转载自www.cnblogs.com/zc1741845455/p/10884787.html
0条评论
添加一条新回复