两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。
package C; public class Bisai { public static void main(String[] args) { String a="xyz",b="",c=""; for (int i = 0; i < 3; i++) { if(a.substring(i,i+1).equals("x")||a.substring(i,i+1).equals("z")) { continue; } System.out.println("c VS "+a.substring(i,i+1)); b=a.replace(a.substring(i,i+1), ""); } for (int i = 0; i < 2; i++) { if(b.substring(i,i+1).equals("x")) { continue; } System.out.println("a VS "+b.substring(i,i+1)); c=b.replace(b.substring(i,i+1), ""); } System.out.println("b VS "+c); } }