用shell写一个猜数字的游戏

我可以帮你写一个猜数字的游戏:#!/bin/bashecho "请输入一个1到100之间的数字:" read numtarget=$(($RANDOM % 100 + 1))while [ $num -ne $target ]; do if [ $num -gt $target ]; then echo "您猜测的数字太大了,请重新猜测:" else echo "您猜测的数字太小了,请重新猜测:" fi read num doneecho "恭喜!您猜中了!"

猜你喜欢

转载自blog.csdn.net/weixin_35754676/article/details/129449751