Advertisement
Guest User

Square of stars.

a guest
Oct 13th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4. int main() {
  5.     int n;
  6.     cin >> n;
  7.     for (int a = 1; a <= n; a = a + 1) {
  8.         for (int b = 1; b <= n; b = b + 1) {
  9.             if (b == 1 || b == n)
  10.                 cout << "*";
  11.             else if (a == 1 || a == n)
  12.                 cout << "*";
  13.             else
  14.                 cout << " ";
  15.         }
  16.         cout << endl;
  17.     }
  18.         return 0;
  19.    
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement