import java.util.Scanner;
public class guess {
public static void main(String[] args) {
Scanner A=new Scanner(System.in);
System.out.println("---猜拳游戏---");
System.out.println("请出拳(1.石头,2.剪刀,3.布)");
int people= A.nextInt();
int computer=(int)(Math.random()*3+1);
if (people==1){
System.out.println("你出的拳是:石头");}
if (people==2){
System.out.println("你出的拳是:剪刀");}
if (people==3){
System.out.println("你出的拳是:布");}
if (computer==1){
System.out.println("电脑出的拳是:石头");}
if (computer==2){
System.out.println("电脑出的拳是:剪刀");}
if (computer==3){
System.out.println("电脑出的拳是:布");}
if (people==computer){
System.out.println("平局");}
else if(people==1&&computer==3||people==2&&computer==1||people==3&&computer==2)
{
System.out.println("电脑赢了! ");}
else{
System.out.println("你赢了!");}
}
}
點擊查看更多內容
1人點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優(yōu)質文章
正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦