Package divideconquer; public class scheduleroundrobin {/* There will n team competition, you must design * a schedule to fill the bill * 1. every team must play with other n-1 Team * 2.a team only take part in a competition * 3.If N is odd, the whole day of competion is n-1; * otherwise, the day is n *** // This is only applicable to the K-power individuals of 2 to participate in the competition, the odd public static void divide (INT data [] [], int N) {If (n = 1) {data [1] [1] = 1; return;} divide (data, n/2); conquer (data, n );} public static void conquer (INT data [] [], int N) {int M = n/2; for (INT I = 1; I <= m; I ++) {for (Int J = 1; j <= m; j ++) {data [I] [J + M] = data [I] [J] + m; data [I + M] [J] = data [I] [J + M]; data [I + M] [J + M] = data [I] [J] ;}} public static void main (string ARGs []) {int n = 14; int data [] [] = new int [n + 1] [n + 1]; divide (data, n + 1); For (INT I = 1; I <n + 1; I ++) {for (Int J = 1; j <n + 1; j ++) system. out. print (data [I] [J] + ""); system. out. println ();}}}
Reprinted: http://blog.sina.com.cn/s/blog_5a16b28c0100efjh.html