downmovies 发表于 2018-8-24 10:51:24

shell练习-----猜数值

#!/usr/bin/env python  
a=`echo $RANDOM | cut -c 1,2`
  
#echo $a                                  /为了验证实验
  
while :; do
  
read -p "please input a number: " x
  
if [ $x == $a ];then
  
      echo "you are right"
  
      break
  
elif [ $x -gt $a ];then
  
      echo "The number what you input is bigger "
  
      continue
  
elif [ $x -lt $a ];then
  
      echo "The number what you input is smaller"
  
      continue
  
fi
  
done


页: [1]
查看完整版本: shell练习-----猜数值