Topic: Two table tennis teams compete, each with three people. Team A is composed of a, b, and c, and team B is composed of x, y, and z.
A lottery has been decided on the game list. Someone asked the players for a list of matches. a said he did not compare with x, c said he did not compare with x, z, please program to find the list of the three teams.
package main; public class NO18 table tennis { static char [] m = {'a', 'b', 'c' }; static char [] n = {'x', 'y', 'z' }; public static void main(String[] args) { // TODO Auto-generated method stub for (int i = 0; i < m.length; i++) { for (int j = 0; j < n.length; j++) { if (m[i] == 'a' && n[j] == 'x') { continue; } else if (m[i] == 'a' && n[j] == 'y') { continue; } else if ((m[i] == 'c' && n[j] == 'x')|| (m[i] == 'c' && n[j] == 'z')) { continue; } else if ((m[i] == 'b' && n[j] == 'z')|| (m[i] == 'b' && n[j] == 'y')) { continue; } else { System.out.println(m[i] + " vs " + n[j]); } } } } }
The running result is:
a vs z
b vs x
c vs y
Reprinted at https://blog.51cto.com/5257890/962831