【java版】飛び込みの達人5人が10メートルの高台飛び込み決勝に参加します。いいことがある人は5人を実力によって試合結果を予測させます。


public class T {
	public static void main(String[] args) {

		boolean[] isRight = new boolean[5]; //            
		int[] personValue = new int[5]; //     5      
		String[] person = new String[] { "A", "B", "C", "D", "E" };//     5   
		for (personValue[0] = 1; personValue[0] <= 5; personValue[0]++)
			for (personValue[1] = 1; personValue[1] <= 5; personValue[1]++)
				for (personValue[2] = 1; personValue[2] <= 5; personValue[2]++)
					for (personValue[3] = 1; personValue[3] <= 5; personValue[3]++)
						for (personValue[4] = 1; personValue[4] <= 5; personValue[4]++) {
							isRight[0] = ((personValue[1] == 2) && (!(personValue[0] == 3)))
									|| ((!(personValue[1] == 2)) && (personValue[0] == 3));
							isRight[1] = ((personValue[1] == 2) && (!(personValue[4] == 4)))
									|| ((!(personValue[1] == 2)) && (personValue[4] == 4));
							isRight[2] = ((personValue[2] == 1) && (!(personValue[3] == 2)))
									|| ((!(personValue[2] == 1)) && (personValue[3] == 2));
							isRight[3] = ((personValue[2] == 5) && (!(personValue[3] == 3)))
									|| ((!(personValue[2] == 5)) && (personValue[3] == 3));
							isRight[4] = ((personValue[4] == 4) && (!(personValue[0] == 1)))
									|| ((!(personValue[4] == 4)) && (personValue[0] == 1));
							if (((isRight[0] && isRight[1] && isRight[2]
									&& isRight[3] && isRight[4]) == true)
									&& (personValue[0] != personValue[1])
									&& (personValue[0] != personValue[2])
									&& (personValue[0] != personValue[3])
									&& (personValue[0] != personValue[4])
									&& (personValue[1] != personValue[2])
									&& (personValue[1] != personValue[3])
									&& (personValue[1] != personValue[4])
									&& (personValue[2] != personValue[3])
									&& (personValue[2] != personValue[4])
									&& (personValue[3] != personValue[4])) {
								for (int i = 0; i < person.length; i++) {
									System.out.println(person[i] + "    :"
											+ personValue[i]);
								}
							}
						}
	}
}
 5       10       ,     5          。
A   :B  ,   ;
B   :   ,E  ;
C   :   ,D  ;
D   :C  ,   ;
E   :   ,A  。
        ,              ,     .            。