#include #include using namespace std; int main() { int rows, cols; int boxWidth, boxHeight; // Ask for rows cout << "Enter number of rows of boxes: "; if (!(cin >> rows) || rows <= 0) { cout << "Invalid input. Must be a positive integer.\n"; return EXIT_FAILURE; } // Ask for columns cout << "Enter number of columns of boxes: "; if (!(cin >> cols) || cols <= 0) { cout << "Invalid input. Must be a positive integer.\n"; return EXIT_FAILURE; } // Ask for box width cout << "Enter number of '-' between '+' in each box (box width): "; if (!(cin >> boxWidth) || boxWidth <= 0) { cout << "Invalid input. Must be a positive integer.\n"; return EXIT_FAILURE; } // Ask for box height cout << "Enter number of '|' per box (box height): "; if (!(cin >> boxHeight) || boxHeight <= 0) { cout << "Invalid input. Must be a positive integer.\n"; return EXIT_FAILURE; } // Draw the grid of boxes for (int r = 0; r < rows; ++r) { // Top border of boxes for (int c = 0; c < cols; ++c) { cout << "+"; for (int i = 0; i < boxWidth; ++i) { cout << "-"; } } cout << "+" << "\n"; // Vertical sides of boxes for (int h = 0; h < boxHeight; ++h) { for (int c = 0; c < cols; ++c) { cout << "|"; for (int i = 0; i < boxWidth; ++i) { cout << " "; } } cout << "|" << "\n"; } } // Final bottom border for (int c = 0; c < cols; ++c) { cout << "+"; for (int i = 0; i < boxWidth; ++i) { cout << "-"; } } cout << "+" << "\n"; return EXIT_SUCCESS; }