## 問題描述

``..\$\$\$\$\$\$\$\$\$\$\$\$\$....\$...........\$..\$\$\$.\$\$\$\$\$\$\$\$\$.\$\$\$\$...\$.......\$...\$\$.\$\$\$.\$\$\$\$\$.\$\$\$.\$\$.\$...\$...\$...\$.\$\$.\$.\$\$\$.\$.\$\$\$.\$.\$\$.\$.\$...\$...\$.\$.\$\$.\$.\$.\$\$\$\$\$.\$.\$.\$\$.\$.\$...\$...\$.\$.\$\$.\$.\$\$\$.\$.\$\$\$.\$.\$\$.\$...\$...\$...\$.\$\$.\$\$\$.\$\$\$\$\$.\$\$\$.\$\$...\$.......\$...\$\$\$\$.\$\$\$\$\$\$\$\$\$.\$\$\$..\$...........\$....\$\$\$\$\$\$\$\$\$\$\$\$\$..``

``1``

``..\$\$\$\$\$....\$...\$..\$\$\$.\$.\$\$\$\$...\$...\$\$.\$\$\$\$\$.\$\$...\$...\$\$\$\$.\$.\$\$\$..\$...\$....\$\$\$\$\$..``

``3``

``..\$\$\$\$\$\$\$\$\$\$\$\$\$....\$...........\$..\$\$\$.\$\$\$\$\$\$\$\$\$.\$\$\$\$...\$.......\$...\$\$.\$\$\$.\$\$\$\$\$.\$\$\$.\$\$.\$...\$...\$...\$.\$\$.\$.\$\$\$.\$.\$\$\$.\$.\$\$.\$.\$...\$...\$.\$.\$\$.\$.\$.\$\$\$\$\$.\$.\$.\$\$.\$.\$...\$...\$.\$.\$\$.\$.\$\$\$.\$.\$\$\$.\$.\$\$.\$...\$...\$...\$.\$\$.\$\$\$.\$\$\$\$\$.\$\$\$.\$\$...\$.......\$...\$\$\$\$.\$\$\$\$\$\$\$\$\$.\$\$\$..\$...........\$....\$\$\$\$\$\$\$\$\$\$\$\$\$..``

## 代碼

``#include <iostream>#include <vector>using namespace std;void printVector2(vector<vector<char> > res) {    for (int i = 0; i < res.size(); i++) {        for (int j = 0; j < res.size(); j++)            cout << res[i][j];        cout << endl;    }}void changeAtRow(int start, int end, int row, vector<vector<char> > &res) {    for (int col = start; col <= end; col++)         res[row][col] = '\$';       }void changeAtCol(int start, int end, int col, vector<vector<char> > &res) {    for (int row = start; row <= end; row++)         res[row][col] = '\$';}void printFlag(int n) {    int  length = 1 + 4 * n + 2 * 2;    vector<vector<char> > res(length, vector<char>(length, '.'));        for (int i = n; i >= 0; i--) {        int start = 2 * (n - i) + 2;        int end = start + 1 + i * 4 - 1;        int row = 2 * (n - i);        int row2 = row + i * 4 + 4;        changeAtRow(start, end, row, res);        changeAtRow(start, end, row2, res);        changeAtCol(row, row + 2, start, res);        changeAtCol(row, row + 2, end, res);        changeAtCol(row2 - 2, row2, start, res);        changeAtCol(row2 - 2, row2, end, res);    }    for (int i = n; i >= 0; i--) {        int start = 2 * (n - i) + 2;        int end = start + 1 + i * 4 - 1;        int col = 2 * (n - i);        int col2 = col + i * 4 + 4;        changeAtCol(start, end, col, res);        changeAtCol(start, end, col + i * 4 + 4, res);        changeAtRow(col, col + 2, start, res);        changeAtRow(col, col + 2, end, res);        changeAtRow(col2 - 2, col2, start, res);        changeAtRow(col2 - 2, col2, end, res);    }            printVector2(res);}int main(int argc, char *argv[]) {    int n;    cin >> n;    printFlag(n);    return 0;}``