Java实现剪刀石头布程序老是说已解析结尾?无奈!!!
importjava.util.Scanner;publicclassJava{publicstaticvoidmain(String[]args){Scannerin=...
import java.util.Scanner;
public class Java{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("-------猜拳游戏------");
System.out.println("请猜拳(1.剪刀 2.石头 3.布)");
int person=in.nextInt();
int computer=(int)(Math.random()*3)+1;
String Marks="拳头";
String Marks="拳头";
switch(person){
case 1:
Marks="剪刀";
break;
case 2:
Marks="石头";
break;
case 3:
Marks="布";
break;
}
switch(person){
case 1:
Marks2="剪刀";
break;
case 2:
Marks2="石头";
break;
case 3:
Marks2="布";
break;
}
if(person==computer){
System.out.println("你出的是:"+Marks+"电脑出的
是:"+Marks2+"平局");
}else if(person==1&&computer==2||person==2&&computer==3||
person==3&&computer==1){
System.out.println("你出的是:"+Marks+"电脑出的
是:"+Marks2+"你输了");
}else{
System.out.println("你出的是:"+Marks+"电脑出的
是:"+Marks2+"你赢了");
}
} 展开
public class Java{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("-------猜拳游戏------");
System.out.println("请猜拳(1.剪刀 2.石头 3.布)");
int person=in.nextInt();
int computer=(int)(Math.random()*3)+1;
String Marks="拳头";
String Marks="拳头";
switch(person){
case 1:
Marks="剪刀";
break;
case 2:
Marks="石头";
break;
case 3:
Marks="布";
break;
}
switch(person){
case 1:
Marks2="剪刀";
break;
case 2:
Marks2="石头";
break;
case 3:
Marks2="布";
break;
}
if(person==computer){
System.out.println("你出的是:"+Marks+"电脑出的
是:"+Marks2+"平局");
}else if(person==1&&computer==2||person==2&&computer==3||
person==3&&computer==1){
System.out.println("你出的是:"+Marks+"电脑出的
是:"+Marks2+"你输了");
}else{
System.out.println("你出的是:"+Marks+"电脑出的
是:"+Marks2+"你赢了");
}
} 展开
1个回答
展开全部
import java.util.Scanner;
public class Java {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("-------猜拳游戏------");
System.out.println("请猜拳(1.剪刀 2.石头 3.布)");
int person = in.nextInt();
int computer = (int) (Math.random() * 3) + 1;
String Marks = "猛闹拳头";
String Marks2 = "拳头";
switch (person) {
case 1:
Marks = "剪液知李刀闹迟";
break;
case 2:
Marks = "石头";
break;
case 3:
Marks = "布";
break;
}
switch (person) {
case 1:
Marks2 = "剪刀";
break;
case 2:
Marks2 = "石头";
break;
case 3:
Marks2 = "布";
break;
}
if (person == computer) {
System.out.println("你出的是:" + Marks + "电脑出的是:" + Marks2 + "平局");
} else if (person == 1 && computer == 2 || person == 2 && computer == 3
||
person == 3 && computer == 1) {
System.out.println("你出的是:" + Marks + "电脑出的是:" + Marks2 + "你输了");
} else {
System.out.println("你出的是:" + Marks + "电脑出的是:" + Marks2 + "你赢了");
}
}
}
public class Java {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("-------猜拳游戏------");
System.out.println("请猜拳(1.剪刀 2.石头 3.布)");
int person = in.nextInt();
int computer = (int) (Math.random() * 3) + 1;
String Marks = "猛闹拳头";
String Marks2 = "拳头";
switch (person) {
case 1:
Marks = "剪液知李刀闹迟";
break;
case 2:
Marks = "石头";
break;
case 3:
Marks = "布";
break;
}
switch (person) {
case 1:
Marks2 = "剪刀";
break;
case 2:
Marks2 = "石头";
break;
case 3:
Marks2 = "布";
break;
}
if (person == computer) {
System.out.println("你出的是:" + Marks + "电脑出的是:" + Marks2 + "平局");
} else if (person == 1 && computer == 2 || person == 2 && computer == 3
||
person == 3 && computer == 1) {
System.out.println("你出的是:" + Marks + "电脑出的是:" + Marks2 + "你输了");
} else {
System.out.println("你出的是:" + Marks + "电脑出的是:" + Marks2 + "你赢了");
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询