SHARE
TWEET

sqrOfStars

a guest Feb 21st, 2020 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top