Advertisement
Guest User

sqrOfStars

a guest
Feb 21st, 2020
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int N;
  9.     cin >> N;
  10.     char star = '*';
  11.     char emptySpace = ' ';
  12.     int emptySpaceQuantity = N - 2;
  13.  
  14.     for (int i = 1; i <= N; i++) {
  15.         if (i == 1) {
  16.             cout << string(N, star) << endl;
  17.         }
  18.         else if (i < N) {
  19.             cout << star << string(emptySpaceQuantity, emptySpace) << star << endl;
  20.         }
  21.         else if (i == N) {
  22.             cout << string(N, star) << endl;
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement