五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

棋盤覆蓋

2023-03-23 11:03 作者:任小蜩  | 我要投稿

#include<iostream>

#include<vector>

#include <algorithm>

#include<cmath>

#include<iomanip>

using namespace std;


int num = 0;//L型骨牌號(hào)

vector<vector<int>> board;

void chessboard(int tr, int tc, int dr, int dc, int size) {

if (size == 1) {

return;

}

int t = num++;//將第num號(hào)骨牌放在棋盤

int s = size / 2;


if (dr < tr + s && dc < tc + s) {//在棋盤左上角

chessboard(tr, tc, dr, dc, s);//規(guī)模縮小一半

}

else {

board[tr + s - 1][tc + s - 1] = t;//將右下角的標(biāo)記,并把它當(dāng)成特殊骨牌,遞歸調(diào)用

chessboard(tr, tc, tr + s - 1, tc + s - 1, s);

}

if (dr < tr + s && dc >= tc + s) {//在右上角

chessboard(tr, tc + s, dr, dc, s);

}

else {

board[tr + s - 1][tc + s] = t;

chessboard(tr, tc + s, tr + s - 1, tc + s, s);

}

if (dr >= tr + s && dc < tc + s)

{

chessboard(tr + s, tc, dr, dc, s);

}

else

{

board[tr + s][tc + s - 1] = t;

chessboard(tr + s, tc, tr + s, tc + s - 1, s);

}

if (dr >= tr + s && dc >= tc + s)

{

chessboard(tr + s, tc + s, dr, dc, s);

}

else

{

board[tr + s][tc + s] = t;

chessboard(tr + s, tc + s, tr + s, tc + s, s);

}


}

int main() {

int dr, dc;//特殊棋子的位置

int tr, tc;//棋盤左上角起始位置

int size;//棋盤大小

cout << "請輸入棋盤大小2^k*2^k中的k:" << endl;

cin >> size;

size = pow(2, size);

cout << "請輸入特殊棋子的行號(hào)和列號(hào)(0 - 2^k-1),用空格隔開:" << endl;

cin >> dr;

cin >> dc;

for (int i = 0; i < size ; i++) {

vector<int> a;

board.push_back(a);

for (int j = 0; j < size ; j++) {

board[i].push_back(-1);? //把棋盤初始化,且所有位置為-1

}

}

chessboard(0, 0, dr, dc, size);

cout << "覆蓋后棋盤如下:" << endl;

for (auto x : board) {

for (auto y : x) {

cout << left << setw(3) << y ;

}

cout<<endl;

}

}


棋盤覆蓋的評(píng)論 (共 條)

分享到微博請遵守國家法律
宁阳县| 扬州市| 民乐县| 定结县| 哈尔滨市| 台中市| 兖州市| 乌什县| 漳州市| 鱼台县| 深水埗区| 高密市| 娄底市| 宜兰市| 神池县| 分宜县| 偃师市| 福贡县| 天峻县| 三河市| 鄂托克前旗| 揭东县| 安西县| 陕西省| 灵台县| 涿州市| 汽车| 东乌| 贵南县| 白朗县| 安岳县| 郴州市| 易门县| 北碚区| 蒙阴县| 黄梅县| 罗源县| 迁安市| 天全县| 颍上县| 葵青区|