//題目:兩個乒乓球隊進行比賽,各出三人。甲隊a, b, c三人, 乙隊x, y, z三人。
//已抽簽決定比賽名單。有人向隊員打聽比賽的名單。
//a說他不和x比,c說他不和x,z比,請編程式找出三隊賽手的名單。
package pratice;
public class Lx18 {
String a, b, c;
public Lx18(String a, String b, String c) {
this.a = a;
this.b = b;
this.c = c;
}
public static void main(String[] args) {
String[] option = {"x", "y", "z"};
for(int i=0; i<3; i++) {
for(int j=0; j<3; j++) {
//一個人只能對打一個
if(i!=j) {
for(int k=0; k<3; k++) {
if(i!=k && j!=k) {
Lx18 lx = new Lx18(option[i], option[j], option[k]);
if(!lx.a.equals("x") && !lx.c.equals("x") && !lx.c.equals("z")) {
System.out.println("a的對手為" +lx.a);
System.out.println("b的對手為" +lx.b);
System.out.println("c的對手為" +lx.c);
}
}
}
}
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/258578.html
標籤:Java EE
