public class Main {
public static void main
(String[] args
) { System.
out.
println("三人でじゃんけんをします(あなたvsCPU2人)。" + "グーなら0、チョキなら1、パーなら2を入力してください。");
int myHand
= new java.
util.
Scanner(System.
in).
nextInt();
int cpuHand1
= new java.
util.
Random().
nextInt(3); int cpuHand2
= new java.
util.
Random().
nextInt(3);
if (cpuHand1 == 0)
System.
out.
println("CPU1の手はグーです。"); else if (cpuHand1 == 1)
System.
out.
println("CPU1の手はチョキです。"); else
System.
out.
println("CPU1の手はパーです。");
if (cpuHand2 == 0)
System.
out.
println("CPU2の手はグーです。"); else if (cpuHand2 == 1)
System.
out.
println("CPU2の手はチョキです。"); else
System.
out.
println("CPU2の手はパーです。");
if (myHand == cpuHand1 && myHand == cpuHand2)
System.
out.
println("あいこでした。"); // ここまで3通り else if (myHand == 0 && cpuHand1 == 1 && cpuHand2 == 2)
System.
out.
println("あいこでした。"); else if (myHand == 0 && cpuHand1 == 2 && cpuHand2 == 1)
System.
out.
println("あいこでした。"); else if (myHand == 1 && cpuHand1 == 2 && cpuHand2 == 0)
System.
out.
println("あいこでした。"); else if (myHand == 1 && cpuHand1 == 0 && cpuHand2 == 2)
System.
out.
println("あいこでした。"); else if (myHand == 2 && cpuHand1 == 0 && cpuHand2 == 1)
System.
out.
println("あいこでした。"); else if (myHand == 2 && cpuHand1 == 1 && cpuHand2 == 0)
System.
out.
println("あいこでした。"); // ここまで9通り
else if (myHand == 0 && cpuHand1 == 1 && cpuHand2 == 1)
System.
out.
println("あなたの勝ちです。"); else if (myHand == 1 && cpuHand1 == 2 && cpuHand2 == 2)
System.
out.
println("あなたの勝ちです。"); else if (myHand == 2 && cpuHand1 == 0 && cpuHand2 == 0)
System.
out.
println("あなたの勝ちです。");
else if (myHand == 1 && cpuHand1 == 0 && cpuHand2 == 1)
System.
out.
println("CPU1の勝ちです。"); else if (myHand == 2 && cpuHand1 == 1 && cpuHand2 == 2)
System.
out.
println("CPU1の勝ちです。"); else if (myHand == 0 && cpuHand1 == 2 && cpuHand2 == 0)
System.
out.
println("CPU1の勝ちです。");
else if (myHand == 1 && cpuHand1 == 1 && cpuHand2 == 0)
System.
out.
println("CPU2の勝ちです。"); else if (myHand == 2 && cpuHand1 == 2 && cpuHand2 == 1)
System.
out.
println("CPU2の勝ちです。"); else if (myHand == 0 && cpuHand1 == 0 && cpuHand2 == 2)
System.
out.
println("CPU2の勝ちです。"); // ここまで18通り
else if (myHand == 0 && cpuHand1 == 0 && cpuHand2 == 1)
System.
out.
println("あなたとCPU1の勝ちです。"); else if (myHand == 1 && cpuHand1 == 1 && cpuHand2 == 2)
System.
out.
println("あなたとCPU1の勝ちです。"); else if (myHand == 2 && cpuHand1 == 2 && cpuHand2 == 0)
System.
out.
println("あなたとCPU1の勝ちです。");
else if (myHand == 0 && cpuHand1 == 1 && cpuHand2 == 0)
System.
out.
println("あなたとCPU2の勝ちです。"); else if (myHand == 1 && cpuHand1 == 2 && cpuHand2 == 1)
System.
out.
println("あなたとCPU2の勝ちです。"); else if (myHand == 2 && cpuHand1 == 0 && cpuHand2 == 2)
System.
out.
println("あなたとCPU2の勝ちです。");
else
System.
out.
println("CPU1とCPU2の勝ちです。"); }
}