simonradev

House

Aug 10th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LiveDemo
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int size = int.Parse(Console.ReadLine());
  14.            
  15.             char asterisk = '*';
  16.             char whiteSpace = ' ';
  17.             char forwardSlash = '/';
  18.             char pipe = '|';
  19.             char dashes = '-';
  20.  
  21.             int countOfMiddleSymbols = 1;
  22.             if (size % 2 == 0)
  23.             {
  24.                 countOfMiddleSymbols = 2;
  25.             }
  26.  
  27.             int countOfDashes = (size - countOfMiddleSymbols) / 2;
  28.  
  29.             string rowToFormat = "{0}{1}{0}";
  30.  
  31.             int rowsOfRoof = (size + 1) / 2;
  32.             for (int currentRow = 0; currentRow < rowsOfRoof; currentRow++)
  33.             {
  34.                 string formattedRow = string.Format(rowToFormat,
  35.                                                     new string(dashes, countOfDashes),
  36.                                                     new string(asterisk, countOfMiddleSymbols));
  37.  
  38.                 countOfDashes--;
  39.                 countOfMiddleSymbols += 2;
  40.  
  41.                 Console.WriteLine(formattedRow);
  42.             }
  43.  
  44.             int rowsOfBody = size / 2;
  45.             for (int currentRow = 0; currentRow < rowsOfBody; currentRow++)
  46.             {
  47.                 string formattedRow = string.Format(rowToFormat,
  48.                                                         pipe,
  49.                                                         new string(asterisk, size - 2));
  50.  
  51.                 Console.WriteLine(formattedRow);
  52.             }
  53.         }
  54.     }
  55. }
Add Comment
Please, Sign In to add comment