#include #include using namespace std; //Function declarations. void graphPaper(int nrows, int ncols, int nrowsb, int ncolsb); void line(int ncols, int ncolsb, char c1, char c2); int main() { //Output four sheets of customized graph paper. graphPaper(10, 10, 1, 4); cout << "\n"; graphPaper(5, 5, 2, 6); cout << "\n"; graphPaper(1, 1, 4, 10); //one big box cout << "\n"; graphPaper(10, 10, 1, 1); //Each box contains just 1 blank. return EXIT_SUCCESS; } //Output graph paper with the given number of rows and columns of boxes. //Each box will contain nrowsb and ncolsb of blanks. void graphPaper(int nrows, int ncols, int nrowsb, int ncolsb) { for (int r {0}; r < nrows; ++r) { line(ncols, ncolsb, '+', '-'); //Single quotes around a char. for (int rb {0}; rb < nrowsb; ++rb) { line(ncols, ncolsb, '|', ' '); } } line(ncols, ncolsb, '+', '-'); } //Output one line of the graph paper, made of the characters c1 and c2. //These characters could be '+' and '-', or they could be '|' and ' '. void line(int ncols, int ncolsb, char c1, char c2) { for (int c {0}; c < ncols; ++c) { //Output c1, followed by ncolsb copies of c2. cout << c1; for (int cb {0}; cb < ncolsb; ++cb) { cout << c2; } } cout << c1; //Output one final c1 at the end of the line. cout << "\n"; }