Java菜鸟练习
//题目:两个乒乓球队进行比赛,各出三人。甲队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);
}
}
}
}
}
}
}
}