Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main ()
- {
- char brick = '#';
- char space = ' ';
- int size = 6;
- int j =0;
- do // this section makes sure the input is valid
- {
- cout << "Please enter size\n(enter an integer between 1 and 100)\n>>";
- cin >> size;
- } while ( size < 1 || size > 100 || isalpha(size)); // only works up to 64, why?
- // //also if you enter a char it goes crazy!
- cout << "Please enter a character for the brick\n>>";
- cin >> brick; // user decides what character to build the pattern out of
- for (int i = 0; i < size; i++) // the rows
- {
- for(j = 0; j < size; j++) // the column
- {
- if (i + j == size - 1 || i == 0 || j == 0) // the logic to decide what to print
- {
- cout << brick;
- }
- else
- {
- cout << space;
- }
- }
- cout << endl; // go to next row
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment