### Magic Square with boxes

So the task is to create a magic square wherein there is actually a box so each number would be in a cell. And I got mine working already but my problem is once the user enters any two-digit number above, the box kinda gets messy so the lines are no longer in place and the box isn't a box anymore. What is the correct algorithm???

Here's what I got so far:

#include <iostream>
#include <iomanip>
#include <windows.h>
#include "ecpe202.h"

void box(int n);

using namespace std;

int main()
{
int n,x,y;

while (n%2 == 0 || n == 1){
cout << "===== MAGIC SQUARE SIMULATOR ====\n\n" << endl;
cout << "Enter an odd number for the size of the Magic Square: ";
cin >> n;
if (n%2 == 0 || n == 1){
cout << "\n\n**** Invalid input. Enter an odd number greater than 1.!!! **** " << "\n";
}
}
clrscr();
//create an array and place 0s in it
int magicSquare[n][n];
for (int i = 0; i < n; i++){
for (int z = 0; z < n; z++){
magicSquare[i][z] = 0;
}
}
//determine first position
int i = 0;
int z = (n - 1)/2;

//first position
magicSquare[i][z] = 1;

int key = 2;
int b, c;

//determining the positions ( from 2 to n*n )
while(key <= n * n ){

//move up and left
b = (i - 1) % n;
c = (z - 1) % n;

// if row is out of bounds
if( b < 0 && c >= 0 ){
i = n - 1;
z = (z - 1)%n;
}

// if col is out of bounds
else if( c < 0 && b >= 0){
z = n - 1;
i = (i - 1) % n;
}

else if( b < 0 && c < 0 ){
i = (i + 1)%n;
}
// if space is occupied, move down
else if(magicSquare[b][c] != 0){
i = (i + 1)%n;
}

//assign b,c to i,z
else {
i = b;
z = c;
//magicSquare[i][z] = key;
}

//put the value in
magicSquare[i][z] = key;
key++;
}
//int common;
box(n);
for (int x = 0; x < n; x++){
for (int y = 0; y < n; y++){
if (n*n < 10){
gotoxy (y*2+1, x * 2 + 1); cout<< magicSquare[x][y];
}else if (n*n<100){
gotoxy (y*3+1,x*2 + 1);cout <<magicSquare [x][y];
}else{
gotoxy (y*4+1,x*2+1); cout <<magicSquare [x][y];
}
}
// common == magicSquare [0][x];
}
// gotoxy (0,n*2+2);cout<< "where the common sum is "<< common << endl;

cout << "\n\nSum of each vertical line: "<< setw(5) << n*(n*n+1)/2 << endl;
cout << "Sum of each horizontal line: " << setw(5) << n*(n*n+1)/2 << endl;
cout << "Sum of each diagonal line: " << setw(3) << n*(n*n+1)/2 <<endl;

/* for (i = 0; i < n; i++){
for (j = 0; j < n; j++){
cout << "|" << setw(5)<<magicSquare[i][j]<<" ";
}
cout<<endl;
} */
/* cout << "Solve for another? Y or N?";
char a;
cin >> a;
if (a == 'y','Y'){
return main();
}
else { */
cout << "\n" <<endl;
return main();
}

void box (int n) {
if (n*n < 10) {
for (int i = 0; i < n * 2 + 1; i++) {
for (int z = 0; z < n * 2 + 1; z++) {
if (i == 0) {
if (z == 0) {
cout << '\xDA';
}
if (z%2 == 1 && z != n * 2 + 1) {
cout << '\xC4';
}
if (z%2 == 0 && z != n * 2 && z != 0) {
cout << '\xC2';
}
if (z == n*2){
cout << '\xBF';
}
}
if (i%2 == 1 && i != n*2 + 1) {
if (z%2 == 1) {
cout << " ";
}else {
cout << '\xB3';
}
}
if (i%2 == 0 && i != 0 && i != n*2) {
if (z == 0) {
cout << '\xC3';
}
if (z%2 == 1 && z != n*2 + 1) {
cout << '\xC4';
}
if (z%2 == 0 && z != n * 2 && z != 0) {
cout << '\xC5';
}
if (z == n*2){
cout << '\xB4';
}
}
if (i == n*2){
if (z == 0) {
cout << '\xC0';
}
if (z%2 == 1 && z != n*2 + 1) {
cout << '\xC4';
}
if (z%2 == 0 && z != n * 2 && z != 0) {
cout << '\xC1';
}
if (z == n*2){
cout << '\xD9';
}
}
}
cout << endl;
}
} else if (n*n < 100) {
for (int i = 0; i < n * 2 + 1; i++) {
for (int z = 0; z < n * 2 + 1; z++) {
if (i == 0) {
if (z == 0) {
cout << '\xDA';
}
if (z%2 == 1 && z != n * 2 + 1) {
cout << '\xC4' << '\xC4';
}
if (z%2 == 0 && z != n * 2 && z != 0) {
cout << '\xC2';
}
if (z == n*2){
cout << '\xBF';
}
}
if (i%2 == 1 && i != n*2 + 1) {
if (z%2 == 1) {
cout << " ";
}else {
cout << '\xB3';
}
}
if (i%2 == 0 && i != 0 && i != n*2) {
if (z == 0) {
cout << '\xC3';
}
if (z%2 == 1 && z != n*2 + 1) {
cout << '\xC4' << '\xC4';
}
if (z%2 == 0 && z != n * 2 && z != 0) {
cout << '\xC5';
}
if (z == n*2){
cout << '\xB4';
}
}
if (i == n*2){
if (z == 0) {
cout << '\xC0';
}
if (z%2 == 1 && z != n*2 + 1) {
cout << '\xC4' << '\xC4';
}
if (z%2 == 0 && z != n * 2 && z != 0) {
cout << '\xC1';
}
if (z == n*2){
cout << '\xD9';
}
}
}
cout << endl;
}
} else {
for (int i = 0; i < n * 2 + 1; i++) {
for (int z = 0; z < n * 2 + 1; z++) {
if (i == 0) {
if (z == 0) {
cout << '\xDA';
}
if (z%2 == 1 && z != n * 2 + 1) {
cout << '\xC4' << '\xC4' << '\xC4';
}
if (z%2 == 0 && z != n * 2 && z != 0) {
cout << '\xC2';
}
if (z == n*2){
cout << '\xBF';
}
}
if (i%2 == 1 && i != n*2 + 1) {
if (z%2 == 1) {
cout << " ";
}else {
cout << '\xB3';
}
}
if (i%2 == 0 && i != 0 && i != n*2) {
if (z == 0) {
cout << '\xC3';
}
if (z%2 == 1 && z != n*2 + 1) {
cout << '\xC4' << '\xC4' << '\xC4';
}
if (z%2 == 0 && z != n * 2 && z !=0){

cout << '\xC5';
}
}
}
}
}
}
and here are the codes for the library "ecpe202.h" which was used above.

#include <windows.h>

#define FOREVER true
#define MAXSTACK 100
#define MAXQUEUE 100

using namespace std;

struct myStack{
int tos;
char s[MAXSTACK];
};

struct myQueue {
int tail;
int q[MAXQUEUE];
};

void createS(myStack &S){
S.tos=-1;
}

void pushS(myStack &S,char item){
S.s[++S.tos]=item;
}
char popS(myStack&S){
return(S.s[S.tos--]);
}

bool isFullS(myStack S){
if(S.tos == MAXSTACK-1)
return (true);
return false;
}

bool isEmptyS(myStack S){
if(S.tos == -1)
return true;
return false;
}
//end of stack

void createQ(myQueue&Q){
Q.tail=0;
}
Q.q[Q.tail++]=item;
Q.tail%=MAXQUEUE;
}
int retrieveQ(myQueue&Q){
int temp;
return (temp);
}
bool isFullQ(myQueue Q){
if(Q.tail == MAXQUEUE)
return (true);
return false;
}
bool isEmptyQ(myQueue Q){
return(true);
return false;
}
void gotoxy(int x,int y){
COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void clrscr(){
system("CLS");
}
http://www.cplusplus.com/articles/jEywvCM9/
Looks like this
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369`` ``````#include #include #include #include "ecpe202.h" void box(int n); using namespace std; int main() { //ask user for size int n, x, y; while (n % 2 == 0 || n == 1) { cout << "===== MAGIC SQUARE SIMULATOR ====\n\n" << endl; cout << "Enter an odd number for the size of the Magic Square: "; cin >> n; if (n % 2 == 0 || n == 1) { cout << "\n\n**** Invalid input. Enter an odd number greater than 1.!!! **** " << "\n"; } } clrscr(); //create an array and place 0s in it int magicSquare[n][n]; for (int i = 0; i < n; i++) { for (int z = 0; z < n; z++) { magicSquare[i][z] = 0; } } //determine first position int i = 0; int z = (n - 1) / 2; //first position magicSquare[i][z] = 1; int key = 2; int b, c; //determining the positions ( from 2 to n*n ) while (key <= n * n) { //move up and left b = (i - 1) % n; c = (z - 1) % n; // if row is out of bounds if (b < 0 && c >= 0) { i = n - 1; z = (z - 1) % n; } // if col is out of bounds else if (c < 0 && b >= 0) { z = n - 1; i = (i - 1) % n; } else if (b < 0 && c < 0) { i = (i + 1) % n; } // if space is occupied, move down else if (magicSquare[b][c] != 0) { i = (i + 1) % n; } //assign b,c to i,z else { i = b; z = c; //magicSquare[i][z] = key; } //put the value in magicSquare[i][z] = key; key++; } //int common; box(n); for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { if (n * n < 10) { gotoxy(y * 2 + 1, x * 2 + 1); cout << magicSquare[x][y]; } else if (n * n < 100) { gotoxy(y * 3 + 1, x * 2 + 1); cout << magicSquare[x][y]; } else { gotoxy(y * 4 + 1, x * 2 + 1); cout << magicSquare[x][y]; } } // common == magicSquare [0][x]; } // gotoxy (0,n*2+2);cout<< "where the common sum is "<< common << endl; cout << "\n\nSum of each vertical line: " << setw(5) << n * (n * n + 1) / 2 << endl; cout << "Sum of each horizontal line: " << setw(5) << n * (n * n + 1) / 2 << endl; cout << "Sum of each diagonal line: " << setw(3) << n * (n * n + 1) / 2 << endl; /* for (i = 0; i < n; i++){ for (j = 0; j < n; j++){ cout << "|" << setw(5)<> a; if (a == 'y','Y'){ return main(); } else { */ cout << "\n" << endl; return main(); } void box(int n) { if (n * n < 10) { for (int i = 0; i < n * 2 + 1; i++) { for (int z = 0; z < n * 2 + 1; z++) { if (i == 0) { if (z == 0) { cout << '\xDA'; } if (z % 2 == 1 && z != n * 2 + 1) { cout << '\xC4'; } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << '\xC2'; } if (z == n * 2) { cout << '\xBF'; } } if (i % 2 == 1 && i != n * 2 + 1) { if (z % 2 == 1) { cout << " "; } else { cout << '\xB3'; } } if (i % 2 == 0 && i != 0 && i != n * 2) { if (z == 0) { cout << '\xC3'; } if (z % 2 == 1 && z != n * 2 + 1) { cout << '\xC4'; } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << '\xC5'; } if (z == n * 2) { cout << '\xB4'; } } if (i == n * 2) { if (z == 0) { cout << '\xC0'; } if (z % 2 == 1 && z != n * 2 + 1) { cout << '\xC4'; } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << '\xC1'; } if (z == n * 2) { cout << '\xD9'; } } } cout << endl; } } else if (n * n < 100) { for (int i = 0; i < n * 2 + 1; i++) { for (int z = 0; z < n * 2 + 1; z++) { if (i == 0) { if (z == 0) { cout << '\xDA'; } if (z % 2 == 1 && z != n * 2 + 1) { cout << '\xC4' << '\xC4'; } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << '\xC2'; } if (z == n * 2) { cout << '\xBF'; } } if (i % 2 == 1 && i != n * 2 + 1) { if (z % 2 == 1) { cout << " "; } else { cout << '\xB3'; } } if (i % 2 == 0 && i != 0 && i != n * 2) { if (z == 0) { cout << '\xC3'; } if (z % 2 == 1 && z != n * 2 + 1) { cout << '\xC4' << '\xC4'; } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << '\xC5'; } if (z == n * 2) { cout << '\xB4'; } } if (i == n * 2) { if (z == 0) { cout << '\xC0'; } if (z % 2 == 1 && z != n * 2 + 1) { cout << '\xC4' << '\xC4'; } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << '\xC1'; } if (z == n * 2) { cout << '\xD9'; } } } cout << endl; } } else { for (int i = 0; i < n * 2 + 1; i++) { for (int z = 0; z < n * 2 + 1; z++) { if (i == 0) { if (z == 0) { cout << '\xDA'; } if (z % 2 == 1 && z != n * 2 + 1) { cout << '\xC4' << '\xC4' << '\xC4'; } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << '\xC2'; } if (z == n * 2) { cout << '\xBF'; } } if (i % 2 == 1 && i != n * 2 + 1) { if (z % 2 == 1) { cout << " "; } else { cout << '\xB3'; } } if (i % 2 == 0 && i != 0 && i != n * 2) { if (z == 0) { cout << '\xC3'; } if (z % 2 == 1 && z != n * 2 + 1) { cout << '\xC4' << '\xC4' << '\xC4'; } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << '\xC5'; } } } } } } /////// #include #define FOREVER true #define MAXSTACK 100 #define MAXQUEUE 100 using namespace std; struct myStack { int tos; char s[MAXSTACK]; }; struct myQueue { int head; int tail; int q[MAXQUEUE]; }; void createS(myStack & S) { S.tos = -1; } void pushS(myStack & S, char item) { S.s[++S.tos] = item; } char popS(myStack & S) { return (S.s[S.tos--]); } bool isFullS(myStack S) { if (S.tos == MAXSTACK - 1) return (true); return false; } bool isEmptyS(myStack S) { if (S.tos == -1) return true; return false; } //end of stack void createQ(myQueue & Q) { Q.head = 0; Q.tail = 0; } void addQ(myQueue & Q, int item) { Q.q[Q.tail++] = item; Q.tail %= MAXQUEUE; } int retrieveQ(myQueue & Q) { int temp; temp = Q.q[Q.head++]; Q.head %= MAXQUEUE; return (temp); } bool isFullQ(myQueue Q) { if (Q.tail == MAXQUEUE) return (true); return false; } bool isEmptyQ(myQueue Q) { if (Q.tail == Q.head) return (true); return false; } void gotoxy(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } void clrscr() { system("CLS"); }``````

> What is the correct algorithm???
You work out the length of the largest integer you're going to print, then arrange for each cell of your square to have that size.

So if your max is say 144, then 3 would be " 3" (or if you're fancy " 3 "), and 42 would be " 42".

No I haven't run your code.

How do I customize the size of the cells of my square? I am currently at a loss
Well the short-term answer is save what you have so that you have at least something to submit, even if it's not ideal.

All non-trivial programs begin with pencil and paper.

Draw a few cells for single digit numbers.
Draw a few cells for two digit numbers.
Draw a few cells for three digit numbers.

Study the relationship between number length and the shape of your cells, and what it takes to draw each cell.

Create prototype programs which you can use to study whether your ideas would work in practice.

What you DON'T want to do is write 100's of lines of code, and then discover the night before that it doesn't work!!!

> How do I customize the size of the cells of my square?
I thought that was what the 'n' parameter to box() was all about.
So anyway, fixed some code.
https://ibb.co/ZTG5TGt

It gets a LOT easier to spot what's missing when you have symbolic constants to represent all the different box elements. You can't see what's missing in a blizzard of hex.
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219`` ``````#include #include #include void box(int n); using namespace std; int main() { //ask user for size int n, x, y; // Yes,your while loop suffered from using uninitialised n do { cout << "===== MAGIC SQUARE SIMULATOR ====\n\n" << endl; cout << "Enter an odd number for the size of the Magic Square: "; cin >> n; if (n % 2 == 0 || n == 1) { cout << "\n\n**** Invalid input. Enter an odd number greater than 1.!!! **** " << "\n"; } } while (n % 2 == 0 || n == 1); box(n); return 0; } #ifdef WINDOWS #else // https://en.wikipedia.org/wiki/Box-drawing_character#Unix,_CP/M,_BBS #define BOX_TL 0x6C #define BOX_HOR 0x71 #define BOX_VTEE 0x77 #define BOX_TR 0x6B #define BOX_VER 0x78 #define BOX_LTEE 0x74 #define BOX_RTEE 0x75 #define BOX_BTEE 0x76 #define BOX_CROSS 0x6E #define BOX_BL 0x6D #define BOX_BR 0x6A std::string boxchar(unsigned char b) { std::ostringstream os; os << "\x1b(0" << b << "\x1b(B"; return os.str(); } #endif void box(int n) { if (n * n < 10) { for (int i = 0; i < n * 2 + 1; i++) { for (int z = 0; z < n * 2 + 1; z++) { if (i == 0) { if (z == 0) { cout << boxchar(BOX_TL); } if (z % 2 == 1 && z != n * 2 + 1) { cout << boxchar(BOX_HOR); } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << boxchar(BOX_VTEE); } if (z == n * 2) { cout << boxchar(BOX_TR); } } if (i % 2 == 1 && i != n * 2 + 1) { if (z % 2 == 1) { cout << " "; } else { cout << boxchar(BOX_VER); } } if (i % 2 == 0 && i != 0 && i != n * 2) { if (z == 0) { cout << boxchar(BOX_LTEE); } if (z % 2 == 1 && z != n * 2 + 1) { cout << boxchar(BOX_HOR); } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << boxchar(BOX_CROSS); } if (z == n * 2) { cout << boxchar(BOX_RTEE); } } if (i == n * 2) { if (z == 0) { cout << boxchar(BOX_BL); } if (z % 2 == 1 && z != n * 2 + 1) { cout << boxchar(BOX_HOR); } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << boxchar(BOX_BTEE); } if (z == n * 2) { cout << boxchar(BOX_BR); } } } cout << endl; } } else if (n * n < 100) { for (int i = 0; i < n * 2 + 1; i++) { for (int z = 0; z < n * 2 + 1; z++) { if (i == 0) { if (z == 0) { cout << boxchar(BOX_TL); } if (z % 2 == 1 && z != n * 2 + 1) { cout << boxchar(BOX_HOR) << boxchar(BOX_HOR); } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << boxchar(BOX_VTEE); } if (z == n * 2) { cout << boxchar(BOX_TR); } } if (i % 2 == 1 && i != n * 2 + 1) { if (z % 2 == 1) { cout << " "; } else { cout << boxchar(BOX_VER); } } if (i % 2 == 0 && i != 0 && i != n * 2) { if (z == 0) { cout << boxchar(BOX_LTEE); } if (z % 2 == 1 && z != n * 2 + 1) { cout << boxchar(BOX_HOR) << boxchar(BOX_HOR); } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << boxchar(BOX_CROSS); } if (z == n * 2) { cout << boxchar(BOX_RTEE); } } if (i == n * 2) { if (z == 0) { cout << boxchar(BOX_BL); } if (z % 2 == 1 && z != n * 2 + 1) { cout << boxchar(BOX_HOR) << boxchar(BOX_HOR); } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << boxchar(BOX_BTEE); } if (z == n * 2) { cout << boxchar(BOX_BR); } } } cout << endl; } } else { for (int i = 0; i < n * 2 + 1; i++) { for (int z = 0; z < n * 2 + 1; z++) { if (i == 0) { if (z == 0) { cout << boxchar(BOX_TL); } if (z % 2 == 1 && z != n * 2 + 1) { cout << boxchar(BOX_HOR) << boxchar(BOX_HOR) << boxchar(BOX_HOR); } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << boxchar(BOX_VTEE); } if (z == n * 2) { cout << boxchar(BOX_TR); } } if (i % 2 == 1 && i != n * 2 + 1) { if (z % 2 == 1) { cout << " "; } else { cout << boxchar(BOX_VER); } } if (i % 2 == 0 && i != 0 && i != n * 2) { if (z == 0) { cout << boxchar(BOX_LTEE); } if (z % 2 == 1 && z != n * 2 + 1) { cout << boxchar(BOX_HOR) << boxchar(BOX_HOR) << boxchar(BOX_HOR); } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << boxchar(BOX_CROSS); } if (z == n * 2) { //!! This was missing cout << boxchar(BOX_RTEE); } } if (i == n * 2) { //!! All this was missing if (z == 0) { cout << boxchar(BOX_BL); } if (z % 2 == 1 && z != n * 2 + 1) { cout << boxchar(BOX_HOR) << boxchar(BOX_HOR) << boxchar(BOX_HOR); } if (z % 2 == 0 && z != n * 2 && z != 0) { cout << boxchar(BOX_BTEE); } if (z == n * 2) { cout << boxchar(BOX_BR); } } } cout << endl; //!! also missing } } }``````

What you should really be thinking about is that the whole interior of the square is common code comprised of nothing more than
 ``12`` ``````cout << " " << boxchar(BOX_VER); cout << boxchar(BOX_HOR) << boxchar(BOX_HOR) << boxchar(BOX_CROSS);``````

You could even pre-create the common elements which depend on the value of n.
Then you wouldn't need the if (n * n < 10) if (n * n < 100) if (n * n < 1000) bloat generator.
 ``12345678`` ``````int len = (int)log10(n*n) + 1; std::ostringstream l1, l2; for ( int i = 0 ; i < len ; i++ ) { l1 << " "; l2 << boxchar(BOX_HOR); } l1 << boxchar(BOX_VER); l2 << boxchar(BOX_CROSS);``````

Last edited on
Voila!
 ``1234567891011121314151617181920212223242526272829303132333435363738394041`` ``````void box(int n) { int len = (int)log10(n*n)+1; // Prepare the oft repeated elements std::ostringstream hdash, hspace; for ( int i = 0 ; i < len ; i++ ) { hdash << boxchar(BOX_HOR); hspace << " "; } // Top Row cout << boxchar(BOX_TL); for ( int c = 0 ; c < n-1 ; c++ ) cout << hdash.str() << boxchar(BOX_VTEE); cout << hdash.str() << boxchar(BOX_TR); cout << endl; // All the cells, except the last row of cells for ( int r = 0 ; r < n-1 ; r++ ) { // spaces and vertical lines cout << boxchar(BOX_VER); for ( int c = 0 ; c < n ; c++ ) cout << hspace.str() << boxchar(BOX_VER); cout << endl; // tee pieces, horizontal lines and crosses cout << boxchar(BOX_LTEE); for ( int c = 0 ; c < n-1 ; c++ ) cout << hdash.str() << boxchar(BOX_CROSS); cout << hdash.str() << boxchar(BOX_RTEE); cout << endl; } // Last row of spaces and vertical lines cout << boxchar(BOX_VER); for ( int c = 0 ; c < n ; c++ ) cout << hspace.str() << boxchar(BOX_VER); cout << endl; // bottom row cout << boxchar(BOX_BL); for ( int c = 0 ; c < n-1 ; c++ ) cout << hdash.str() << boxchar(BOX_BTEE); cout << hdash.str() << boxchar(BOX_BR); cout << endl; }``````
Thank you so much!! You're a life saver