Advertisement
darrellp

Hollow Square

Nov 17th, 2021
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. void printHollowSquare(int n)
  2. {
  3.     string topBottom = string(n, '*');
  4.     string middle = '*' + string(n - 2, ' ') + '*';
  5.     cout << topBottom << endl;
  6.     for (int iRow = 1; iRow < n - 1; iRow++)
  7.     {
  8.         cout << middle << endl;
  9.     }
  10.     cout << topBottom << endl;
  11. }
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement