帮我改写一下这段程序,要求更换为不使用templatetemplate <size_t ARRAY_SIZE> void common_print_border(struct INFORMATION(*information)[ARRAY_SIZE], int L, int C, int cell_width, int cell_height, bool inner_border) { int X = 0, Y = 0; for (int j = 0; j < C; j++) { X = 3 + cell_width / 2 + j * (cell_width + 2 * inner_border); cct_showch(X, 1, information[0][j].C); } for (int i = 0; i < L; i++) { Y = 3 + i * (cell_height + inner_border); if (i == 0) { cct_showstr(2, 2, "╔", COLOR_HWHITE, COLOR_BLACK); for (int j = 0; j < C; j++) { X = 4 + j * (cell_width + 2 * inner_border); cct_showstr(X, 2, "═", COLOR_HWHITE, COLOR_BLACK, cell_width / 2); if (inner_border && j < C - 1) { X += cell_width; cct_showstr(X, 2, "╦", COLOR_HWHITE, COLOR_BLACK); } } X += cell_width; cct_showstr(X, 2, "╗", COLOR_HWHITE, COLOR_BLACK); } for (int j = 0; j <= C; j++) { if (inner_border || j == 0 || j == C) { X = 2 + j * (cell_width + 2 * inner_border); if (!inner_border && j == C) { X += 2; } for (int k = 0; k < cell_height; k++) { if (k == cell_height / 2) { cct_showch(0, Y + k, information[i][0].L); } cct_showstr(X, Y + k, "║", COLOR_HWHITE, COLOR_BLACK); } } } Y += cell_height; if (inner_border && i < L - 1) { cct_showstr(2, Y, "╠", COLOR_HWHITE, COLOR_BLACK); for (int j = 0; j < C; j++) { X = 4 + j * (cell_width + 2 * inner_border); cct_showstr(X, Y, "═", COLOR_HWHITE, COLOR_BLACK, cell_width / 2); X += cell_width; cct_showstr(X, Y, (j < C - 1) ? "╬" : "╣", COLOR_HWHITE, COLOR_BLACK); } } if (i == L - 1) { cct_showstr(2, Y, "╚", COLOR_HWHITE, COLOR_BLACK); for (int j = 0; j < C; j++) { X = 4 + j * (cell_width + 2 * inner_border); cct_showstr(X, Y, "═", COLOR_HWHITE, COLOR_BLACK, cell_width / 2); if (inner_border && j < C - 1) { X += cell_width; cct_showstr(X, Y, "╩", COLOR_HWHITE, COLOR_BLACK); } } X += cell_width; cct_showstr(X, Y, "╝", COLOR_HWHITE, COLOR_BLACK); } } return; }
时间: 2024-03-30 21:34:10 浏览: 55
以下是不使用template的改写程序:
void common_print_border(struct INFORMATION information[][ARRAY_SIZE], int L, int C, int cell_width, int cell_height, bool inner_border) {
int X = 0, Y = 0;
for (int j = 0; j < C; j++) {
X = 3 + cell_width / 2 + j * (cell_width + 2 * inner_border);
cct_showch(X, 1, information[0][j].C);
}
for (int i = 0; i < L; i++) {
Y = 3 + i * (cell_height + inner_border);
if (i == 0) {
cct_showstr(2, 2, "╔", COLOR_HWHITE, COLOR_BLACK);
for (int j = 0; j < C; j++) {
X = 4 + j * (cell_width + 2 * inner_border);
cct_showstr(X, 2, "═", COLOR_HWHITE, COLOR_BLACK, cell_width / 2);
if (inner_border && j < C - 1) {
X += cell_width;
cct_showstr(X, 2, "╦", COLOR_HWHITE, COLOR_BLACK);
}
}
X += cell_width;
cct_showstr(X, 2, "╗", COLOR_HWHITE, COLOR_BLACK);
}
for (int j = 0; j <= C; j++) {
if (inner_border || j == 0 || j == C) {
X = 2 + j * (cell_width + 2 * inner_border);
if (!inner_border && j == C) {
X += 2;
}
for (int k = 0; k < cell_height; k++) {
if (k == cell_height / 2) {
cct_showch(0, Y + k, information[i][0].L);
}
cct_showstr(X, Y + k, "║", COLOR_HWHITE, COLOR_BLACK);
}
}
}
Y += cell_height;
if (inner_border && i < L - 1) {
cct_showstr(2, Y, "╠", COLOR_HWHITE, COLOR_BLACK);
for (int j = 0; j < C; j++) {
X = 4 + j * (cell_width + 2 * inner_border);
cct_showstr(X, Y, "═", COLOR_HWHITE, COLOR_BLACK, cell_width / 2);
X += cell_width;
cct_showstr(X, Y, (j < C - 1) ? "╬" : "╣", COLOR_HWHITE, COLOR_BLACK);
}
}
if (i == L - 1) {
cct_showstr(2, Y, "╚", COLOR_HWHITE, COLOR_BLACK);
for (int j = 0; j < C; j++) {
X = 4 + j * (cell_width + 2 * inner_border);
cct_showstr(X, Y, "═", COLOR_HWHITE, COLOR_BLACK, cell_width / 2);
if (inner_border && j < C - 1) {
X += cell_width;
cct_showstr(X, Y, "╩", COLOR_HWHITE, COLOR_BLACK);
}
}
X += cell_width;
cct_showstr(X, Y, "╝", COLOR_HWHITE, COLOR_BLACK);
}
}
return;
}
阅读全文