Advertisement
Guest User

#2

a guest
Oct 15th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     short unsigned int n;
  8.     cin >> n;
  9.     char array[n][n];
  10.  
  11.     //fill
  12.     for (int x = 0; x < n; x++) {
  13.         for (int y = 0; y < n; y++) {
  14.             if ((x - y == 0) || ((n - 1) / 2 == y) || ((n - 1) / 2 == x) || (y + x == n - 1))
  15.             {
  16.                 array[x][y] = '*';
  17.             }
  18.             else
  19.             {
  20.                 array[x][y] = '.';
  21.             }
  22.         }
  23.     }
  24.    
  25.     //output
  26.     for (int x = 0; x < n; x++) {
  27.         for (int y = 0; y < n; y++) {
  28.             cout<<array[x][y]<<" ";
  29.         }
  30.         cout<<endl;
  31.     }
  32.  
  33.  
  34.     return 0;
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement