标签:
String str = "abc";
char ch = str.charAt(0);
char ch2 = str.charAt(1);
import java.util.Scanner;
public class Test02{
public static void main(String args[]){
Scanner p = new Scanner(System.in);
System.out.println("Player1 first:");
String p1 = p.next();
char play1 = p1.charAt(0);
System.out.println("Player2 please:");
String p2 = p.next();
char play2 = p2.charAt(0);
if ((play1 == ‘s‘|play1 == ‘j‘|play1 == ‘b‘)&(play2 == ‘s‘|play2 == ‘j‘|play2 == ‘b‘)){
if(play1 == play2){
System.out.println("平");
}
else if(play1 == ‘s‘){
if(play2 == ‘j‘){
System.out.println("player1胜");
}
else{
System.out.println("player2胜");
}
}
else if(play1 == ‘j‘){
if(play2 == ‘b‘){
System.out.println("player1胜");
}
else{
System.out.println("player2胜");
}
}
else if(play1 == ‘b‘){
if(play2 == ‘s‘){
System.out.println("player1胜");
}
}
}
else{
System.out.println("输入有误");
}
}
}
标签:
原文地址:http://www.cnblogs.com/livterjava/p/4696326.html