题目:两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。
public static void test7(){
int a = 1;
int b = 2;
int c = 3;
for(int x = a; x <= c ; x++){
if(x == a || x == c){
continue;
}
for(int y = a; y <= c; y++){
if(y == x){
continue;
}
for(int z = a; z <= c; z++){
if( z == c || z == x || z == y){
continue;
}
if(x != y && x != z && y !=z){
System.out.println("x的对手是第"+x+"位");
System.out.println("y的对手是第"+y+"位");
System.out.println("z的对手是第"+z+"位");
break;
}
}
}
}
}
int a = 1;
int b = 2;
int c = 3;
for(int x = a; x <= c ; x++){
if(x == a || x == c){
continue;
}
for(int y = a; y <= c; y++){
if(y == x){
continue;
}
for(int z = a; z <= c; z++){
if( z == c || z == x || z == y){
continue;
}
if(x != y && x != z && y !=z){
System.out.println("x的对手是第"+x+"位");
System.out.println("y的对手是第"+y+"位");
System.out.println("z的对手是第"+z+"位");
break;
}
}
}
}
}