{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "aa7fe92bbd9b4b039034264e025596fd",
  "keywords": "算法初阶,基础知识,随机算法,概率分析和随机算法",
  "title": "设计一个“石头剪刀布”游戏程序。",
  "desc": [
    {
      "content": "\n<p>设计一个“石头剪刀布”游戏程序。用户和程序分别扮演猜拳双方&#xff0c;用户选择</p><p>石头、剪刀和布中的一项&#xff0c;程序随机选择另一项&#xff0c;与用户选择作比较&#xff0c;在界面中</p><p>显示最终的胜负判定。</p>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include <stdlib.h>\n#include <stdio.h>\nint main()\n{\n\tint id;\n\tint a[3]={1,2,3};\n\tint au = 0;\n\twhile(1)\n\t{\n\t\tprintf(\"1.剪刀,2.石头,3.布,0.退出\\n\");\n\t\tscanf(\"%d\",&id);\n\t\tif(id == 0)\n\t\t\tbreak;\n\t\tau = a[rand()%3]; \n\t\tif (au == 1)\n\t\t{\n\t\t\tprintf(\"机器：剪刀\\t\");\n\t\t\tif(id == 1)\n\t\t\t\tprintf(\"玩家:剪刀\\t平局\\n\");\n\t\t\telse if(id == 2)\n\t\t\t\tprintf(\"玩家:石头\\t玩家赢\\n\");\n\t\t\telse\n\t\t\t\tprintf(\"玩家:布\\t机器赢\\n\");\n\t\t}\n\t\telse if(au == 2)\n\t\t{\n\t\t\tprintf(\"机器：石头\\t\");\n\t\t\tif(id == 1)\n\t\t\t\tprintf(\"玩家:剪刀\\t机器赢\\n\");\n\t\t\telse if(id == 2)\n\t\t\t\tprintf(\"玩家:石头\\t平局\\n\");\n\t\t\telse\n\t\t\t\tprintf(\"玩家:布\\t玩家赢\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"机器：布\\t\");\n\t\t\tif(id == 1)\n\t\t\t\tprintf(\"玩家:剪刀\\t玩家赢\\n\");\n\t\t\telse if(id == 2)\n\t\t\t\tprintf(\"玩家:石头\\t机器赢\\n\");\n\t\t\telse\n\t\t\t\tprintf(\"玩家:布\\t平局\\n\");\n\t\t}\n\t}\n\treturn 0;\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-f74d4a8827134b95be99a1cc4e069db0",
  "license": "csdn.net",
  "created_at": 1637894160,
  "topic_link": "https://bbs.csdn.net/topics/600470247"
}