Advertisement
noob339

mario_cpp

Oct 18th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void numOfCharacters(int numchar, char character)
  6. {
  7.     for (int i = 0; i < numchar; i++)
  8.     {
  9.         cout << char(character);
  10.     }
  11. }
  12.  
  13. void drawOneRow(int rowNum, int width, char c1, char c2)
  14. {
  15.     int numOfCharOne = width - rowNum - 1;
  16.     int numOfCharTwo = rowNum + 1;
  17.     numOfCharacters(numOfCharOne, c1);
  18.     numOfCharacters(numOfCharTwo, c2);
  19.     cout << " ";
  20.     numOfCharacters(numOfCharTwo, c2);
  21. }
  22.  
  23. int main(void)
  24. {
  25.     int h;
  26.     do
  27.     {
  28.     cout << "Enter Width: ";
  29.     cin >> h;
  30.     }
  31.     while (h < 0 && h > 8);
  32.    
  33.    
  34.     for (int n = 0; n < h; n++)
  35.     {
  36.         drawOneRow(n, h, ' ', '#');
  37.         cout << endl;
  38.     }
  39.    
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement