fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void square(int n)
  6. {
  7. for(int row = 0; row < n; ++row)
  8. {
  9. for(int col = 0; col < n; ++col)
  10. cout << (row == col || row + col == n - 1 ||
  11. abs(2*row - n + 1) < 2 || abs(2*col - n + 1) < 2 ? '*' : '.');
  12. cout << "\n";
  13. }
  14. }
  15.  
  16.  
  17. int main()
  18. {
  19. int n;
  20. cin >> n;
  21. square(n);
  22. }
  23.  
  24.  
Success #stdin #stdout 0s 5532KB
stdin
15

stdout
*......*......*
.*.....*.....*.
..*....*....*..
...*...*...*...
....*..*..*....
.....*.*.*.....
......***......
***************
......***......
.....*.*.*.....
....*..*..*....
...*...*...*...
..*....*....*..
.*.....*.....*.
*......*......*