分析家 发表于 2018-8-26 10:21:09

人机猜拳游戏(自己编写shell脚本)

  #!/bin/bash
  read -p "请输入你的选择(石头 剪刀 布):" b0
  a0=$
  #1为石头2为剪刀3为布
  if [ $a0 -eq 1 ];then
  if [ $b0 == 石头 ];then &>/dev/null
  echo "平局"
  elif [ $b0 == 剪刀 ];then &>/dev/null
  echo "你输了=="
  elif [ $b0 == 布 ];then &>/dev/null
  echo "恭喜你,你赢了!"
  else
  echo "请输入正确的选择"
  fi
  elif [ $a0 -eq 2 ];then
  if [ $b0 == 石头 ];then &>/dev/null
  echo "恭喜你,你赢了!"
  elif [ $b0 == 剪刀 ];then &>/dev/null
  echo "平局"
  elif [ $b0 == 布 ];then &>/dev/null
  echo "你输了=="
  else
  echo "请输入正确的选择"
  fi
  else
  if [ $b0 == 石头 ];then &>/dev/null
  echo "你输了=_="
  elif [ $b0 == 剪刀 ];then &>/dev/null
  echo "恭喜你,你赢了!"
  elif [ $b0 == 布 ]; then &>/dev/null
  echo "平局"
  else
  echo "请输入正确的选择"
  fi
  fi
  ~

页: [1]
查看完整版本: 人机猜拳游戏(自己编写shell脚本)