单循环比赛程序

有偶数支足球队进行单循环比赛,请按照指定算法打印每轮的对阵形势
public class ArrayDemo3 {
	public static void main(String[] args) {
		planGame();
	}
	public static void planGame(){
		String[] teams=new String[]{"T1","T2","T3","T4"};
		for (int i = 1; i < teams.length; i++) {
			System.out.println();
			System.out.println("这是第"+i+"轮比赛");
			for (int j = 0; j < teams.length/2; j++) {
				System.out.println(teams[j]+" VS "+teams[teams.length-1-j]);
			}
			String temp = teams[teams.length - 1];
			for(int k = teams.length-1;k > 1;k--){
				teams[k] = teams[k - 1];
			}
			teams[1] = temp;
		}
	}
}

你可能感兴趣的:(java,算法,teams)