Home > Back-end >  Java novice practice
Java novice practice

Time:02-11


//title: two table tennis team for the game, each out of three people, a team a, b, c three, b team x, y, z three,
//have a lottery game list, someone asked the players the game list,
//a said he didn't than x, c says he doesn't x, z, program, please find out the three team player list,
Package pratice.
Public class Lx18 {
String a, b, c;
Public Lx18 (String a and String b, c) String {
Enclosing a=a;
This. B=b;
This. C=c;
}
Public static void main (String [] args) {
The option String []={" x ", "y", "z"};
for(int i=0; I<3; I++) {
for(int j=0; J<3; J++) {
//a person can only play a
If (I. J)={
For (int k=0; K<3; K++) {
If (I.=k & amp; & J! K)={
Lx18 lx=new Lx18 (option [I], option [j], option [k]);
if(! Lx, a.e quals (" x ") & amp; & ! Lx. C.e quals (" x ") & amp; & ! Lx. C.e quals (" z ")) {
System. The out. Println (" is a rival to "+ lx. A);
System. The out. Println (" b opponent as "+ lx. B);
System. The out. Println (" c opponents as "+ lx. C);
}
}
}
}
}
}
}
}
  • Related