Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void numOfCharacters(int numchar, char character)
- {
- for (int i = 0; i < numchar; i++)
- {
- cout << char(character);
- }
- }
- void drawOneRow(int rowNum, int width, char c1, char c2)
- {
- int numOfCharOne = width - rowNum - 1;
- int numOfCharTwo = rowNum + 1;
- numOfCharacters(numOfCharOne, c1);
- numOfCharacters(numOfCharTwo, c2);
- cout << " ";
- numOfCharacters(numOfCharTwo, c2);
- }
- int main(void)
- {
- int h;
- do
- {
- cout << "Enter Width: ";
- cin >> h;
- }
- while (h < 0 && h > 8);
- for (int n = 0; n < h; n++)
- {
- drawOneRow(n, h, ' ', '#');
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement