标签:rip 输出 syn java 选择 OLE code int sync
const readline = require("readline-sync"); //输出功能 console.log("欢迎进入猜拳游戏"); console.log("请选择出拳:1. 石头 2.剪刀 3.布"); let option = readline.question() - 0; while (isNaN(option) || option < 1 || option > 3) { console.log("请重输:"); option = readline.question() - 0; } //电脑随机出拳 let random = parseInt(Math.random() * 3 + 1); if (random == 1) { console.log("电脑出拳为:石头"); }else if(random == 2){ console.log("电脑出拳为:剪刀"); }else{ console.log("电脑出拳为:布"); } //玩家出拳 if (option == 1) { console.log("玩家出拳为:石头"); }else if(option == 2){ console.log("玩家出拳为:剪刀"); }else{ console.log("玩家出拳为:布"); } //判断 function name(a, b) { if (a - b == -1 || a - b == 2) { console.log("电脑胜利"); }else if(a - b == 0){ console.log("平局"); }else{ console.log("玩家胜利"); } } name(random, option)
标签:rip 输出 syn java 选择 OLE code int sync
原文地址:https://www.cnblogs.com/cj-18/p/9097530.html