有六个对 1,2,3,4,5,6 用数组 算出有5轮对战模式1--》6
2--》5
3--》5
1--》5
6--》4
2--》3
1--》4
5--》3
6--》2
1--》3
4--》2
5--》61--》2
3--》6
4--》52,3,4,5,6 按u型循环一圈 打印对战模式
2--》5
3--》5
1--》5
6--》4
2--》3
1--》4
5--》3
6--》2
1--》3
4--》2
5--》61--》2
3--》6
4--》52,3,4,5,6 按u型循环一圈 打印对战模式
public static void main(String[] args) {
int[] input = new int[0];
int[] output = new int[0];
int i,z,k = 1,s = 1,n;
System.out.print("请输入球队数量");
i =SystemIn.readInt();
for(int j=1;j<=i;j++) {
System.out.print("请输入球队编号");
int c = SystemIn.readInt();
input = push(c,input);
}
if(i%2!=0) {
input=push(0,input);
}
output=input;
z = input[1];
do {
int log;
System.out.println("第"+s+"轮对阵表");
while(input.length>0) {
System.out.println(input[0]+"对阵"+input[input.length-1]);
input=pop(input);
}
input=lunzhuan(output);
s++;
}while(input[1]!=z);
}
public static int[] push(int c,int[] i){
int[] i_c = new int[i.length+1];
System.arraycopy(i, 0, i_c, 0, i.length);
i_c[i_c.length-1] = c;
return i=i_c;
}
public static int[] pop(int[] j) {
int[] v_c = new int[j.length-2];
System.arraycopy(j, 1, v_c, 0, j.length-2);
j=v_c;
return j;
}
public static int[] lunzhuan(int[] i) {
int j = i[i.length-1];
int k = 1;
while(i.length-k>1) {
i[i.length-k] = i[i.length-k-1];
if(i.length-k==2) {
i[1] = j;
}
k++;
}
return i;
}
}