4. There are two teams of 5 players per team for a one-on game, a team for a, B, C, D, E, Team B for J, K, L, M, N, after a lot of lottery to determine the competition opponent list. Rules a not and J match, M not and D and e match. List all the possible matches.
Tip: First fixed a team, a in the No. 0 position, b in the 1th digits, arranged sequentially, the last E in the 4th position, and then team B corresponding opponent, with the loop variable J, K, L, m, n respectively corresponding to the choice of No. 0 digits, the choice of 1th digits, and so on,
Until the choice of position 4th, each layer of the cycle should be excluded from the previous round of the selected contestant, and designated not match with the opponent. Use variable I to count the different cases.
public class Hzs4 {
public static void Main (string[] args)
{
String s1[]={"A", "B", "C", "D", "E"};
String s2[]={"J", "K", "L", "M", "N"};
for (int i=0;i<5;i++)
{
if (S2[i]!=s2[0])
{
System.out.println (s1[0]+ "," +s2[i]);
}
}
for (int i=0;i<5;i++)
{
System.out.println (s1[1]+ "," +s2[i]);
}
for (int i=0;i<5;i++)
{
System.out.println (s1[2]+ "," +s2[i]);
}
for (int i=0;i<5;i++)
{
if (S2[i]!=s2[3])
{
System.out.println (s1[3]+ "," +s2[i]);
}
}
for (int i=0;i<5;i++)
{
if (S2[i]!=s2[3])
{
System.out.println (s1[3]+ "," +s2[i]);
}
}
}
}
Two teams of 5 players per team for one-on game (algorithm)