Two table tennis teams compete to find out the names of the players of the three teams

From , 3 Years ago, written in Java, viewed 80 times.
URL https://pastebin.vip/view/051e4e12
  1. import java.util.ArrayList;
  2.  
  3. /**
  4.  * 两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比,c说他不和x,
  5.  * z比,请编程序找出三队赛手的名单。
  6.  */
  7. public class pingpang {
  8.         String a, b, c;
  9.  
  10.         public static void main(String[] args) {
  11.                 String[] op = { "x", "y", "z" };
  12.                 ArrayList<pingpang> arrayList = new ArrayList<pingpang>();
  13.                 for (int i = 0; i < 3; i++)
  14.                         for (int j = 0; j < 3; j++)
  15.                                 for (int k = 0; k < 3; k++) {
  16.                                         pingpang a = new pingpang(op[i], op[j], op[k]);
  17.                                         if (!a.a.equals(a.b) && !a.b.equals(a.c)
  18.                                                         && !a.a.equals("x") && !a.c.equals("x")
  19.                                                         && !a.c.equals("z")) {
  20.                                                 arrayList.add(a);
  21.                                         }
  22.                                 }
  23.                 for (Object a : arrayList) {
  24.                         System.out.println(a);
  25.                 }
  26.         }
  27.  
  28.         public pingpang(String a, String b, String c) {
  29.                 super();
  30.                 this.a = a;
  31.                 this.b = b;
  32.                 this.c = c;
  33.         }
  34.  
  35.         @Override
  36.         public String toString() {
  37.                 // TODO Auto-generated method stub
  38.                 return "a的对手是" + a + "," + "b的对手是" + b + "," + "c的对手是" + c + "\n";
  39.         }
  40. }
  41.  

Reply to "Two table tennis teams compete to find out the names of the players of the three teams"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website