⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 table.java

📁 《算法设计与分析》王晓东编著
💻 JAVA
字号:
import java.util.Scanner;
public class Table {

	public static int[][] table;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		System.out.print("Please input the number of players n(n=2^k):");
		int n = in.nextInt();
		table = new int[n][n];
		for(int i=0;i<n;i++){
			table[i][0] = i+1;
		}
		table(0,0,n);
		System.out.print("Match table:\n");
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				System.out.print(table[i][j]+"\t");
			}
			System.out.println();
		}
	}
	public static void table(int x,int y,int size){
		if (size==1) return;
		int s = size/2;
		table(x,y,s);
		table(x+s,y,s);
		copyArea(x+s,y,x,y+s,s);
		copyArea(x,y,x+s,y+s,s);
		
		
	}
	public static void copyArea(int sx,int sy,int dx,int dy,int s){
		for(int i=0;i<s;i++){
			for(int j=0;j<s;j++)
				table[dx+i][dy+j] = table[sx+i][sy+j];
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -