fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. ostream &printHex(ostream &out, size_t size) {
  5. static const char borderChar = '#';
  6. static const char fillChar = '.';
  7. static const char indentationChar = ' ';
  8.  
  9. out << string(size-1, indentationChar) << string(size, borderChar) << endl;
  10. if (size<=1)
  11. return out;
  12. for (size_t line=1; line<size-1; ++line) {
  13. out << string(size-1-line, indentationChar) << borderChar << string(size+2*(line-1), fillChar) << borderChar<< endl;
  14. }
  15. for (size_t line=size-1; line>0; --line) {
  16. out << string(size-1-line, indentationChar) << borderChar << string(size+2*(line-1), fillChar) << borderChar << endl;
  17. }
  18. out << string(size-1, indentationChar) << string(size, borderChar) << endl;
  19. return out;
  20. }
  21. int main() {
  22. size_t size;
  23.  
  24. while(cin>>size) {
  25. printHex(cout, size) << endl;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 3436KB
stdin
1
2
3
5
stdout
#

 ##
#..#
 ##

  ###
 #...#
#.....#
 #...#
  ###

    #####
   #.....#
  #.......#
 #.........#
#...........#
 #.........#
  #.......#
   #.....#
    #####