Geek攻城猫
2018-04-08 16:28:37浏览 2550
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("你赢了!");}
}
}