Ejemplo n.º 1
0
void chess_cover(int tr, int tc, int dr, int dc, int size) {
	if(size == 1) return;
	int t = L_no++; //L型牌的编号
	int s = size / 2;
	//覆盖左上角的棋盘
	if((dr < tr + s) && (dc < tc + s)) {
		chess_cover(tr, tc, dr, dc, s);
	}else {
		chess[tr+s-1][tc+s-1] = t;
		chess_cover(tr, tc, tr+s-1, tc+s-1, s);
	}
	if (dr < tr + s && dc >= tc + s){
		chess_cover(tr, tc+s, dr, dc, s);
	}else {        
		chess[tr + s - 1][tc + s] = t;
      	chess_cover(tr, tc+s, tr+s-1, tc+s, s);
    }
        // 覆盖左下角子棋盘
    if (dr >= tr + s && dc < tc + s){
    	chess_cover(tr+s, tc, dr, dc, s);
    }else {
    	chess[tr + s][tc + s - 1] = t;
    	chess_cover(tr+s, tc, tr+s, tc+s-1, s);
    }
    if (dr >= tr + s && dc >= tc + s){
       chess_cover(tr+s, tc+s, dr, dc, s);
    }else {
       chess[tr + s][tc + s] = t;
       chess_cover(tr+s, tc+s, tr+s, tc+s, s);
   }
}
Ejemplo n.º 2
0
void chess_cover(int tr, int tc, int dr, int dc, int size) {

    if (size == 1) {
        return;
    }

    int s = size / 2;
    int t = cell_num++;

    //左上角
    if (dr < tr + s && dc < tc + s)chess_cover(tr, tc, dr, dc, s);
    else {
        chess_board[tr + s - 1][tc + s - 1] = t;
        chess_cover(tr, tc, tr + s - 1, tc + s - 1, s);
    }

    //右上角
    if (dr < tr + s && dc >= tc + s) chess_cover(tr, tc + s, dr, dc, s);
    else {
        chess_board[tr + s - 1][tc + s] = t;
        chess_cover(tr, tc + s, tr + s - 1, tc + s, s);
    }

    //左下角
    if (dr >= tr + s && dc < tc + s) chess_cover(tr + s, tc, dr, dc, s);
    else {
        chess_board[tr + s][tc + s - 1] = t;
        chess_cover(tr + s, tc, tr + s, tc + s - 1, s);
    }

    //右下角
    if (dr >= tr + s && dc >= tc + s)chess_cover(tr + s, tc + s, dr, dc, s);
    else {
        chess_board[tr + s][tc + s] = t;
        chess_cover(tr + s, tc + s, tr + s, tc + s, s);
    }
}
Ejemplo n.º 3
0
int main(int argc, char *argv[]){
	if(argc < 3) {
		usage();
		return 1;
	}
	int dr, dc;
	dr = atoi(argv[1]);
	dc = atoi(argv[2]);
	if((dr >= CHESS_SIZE) || (dc >= CHESS_SIZE) || (dr < 0) || (dc < 0)){
		out_of_range();
		return 1;
	}
	int i,j;
	chess_cover(0, 0, dr, dc, CHESS_SIZE);
	for(i = 0; i < CHESS_SIZE; i++) {
		for(j = 0; j < CHESS_SIZE; j++) {
			printf("%d  ", chess[i][j]);
		}
		printf("\n");
	}
	printf("\n");
	return 0;
}
Ejemplo n.º 4
0
int main() {
    chess_cover(0, 0, 1, 2, SIZE);
    print();
    return 0;
}