Advertisement
simonradev

Sunglasses

Aug 10th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 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.            
  20.             string rowToFormat = "*{0}*{1}*{0}*";
  21.  
  22.             int countOfMiddleSymbols = size * 2 - 2;
  23.  
  24.             string firstAndLastRow = string.Format(rowToFormat,
  25.                                                    new string(asterisk, countOfMiddleSymbols),
  26.                                                    new string(whiteSpace, size));
  27.  
  28.             Console.WriteLine(firstAndLastRow);
  29.  
  30.             int rows = size - 2;
  31.  
  32.             int rowOfNeshtoSi = (int)(Math.Ceiling(size / 2.0) - 2);
  33.             for (int currentRow = 0; currentRow < rows; currentRow++)
  34.             {
  35.                 char currentMiddleSymbol = whiteSpace;
  36.                 if (currentRow == rowOfNeshtoSi)
  37.                 {
  38.                     currentMiddleSymbol = pipe;
  39.                 }
  40.  
  41.                 string formattedRow = string.Format(rowToFormat,
  42.                                                     new string(forwardSlash, countOfMiddleSymbols),
  43.                                                     new string(currentMiddleSymbol, size));
  44.  
  45.                 Console.WriteLine(formattedRow);
  46.             }
  47.  
  48.             Console.WriteLine(firstAndLastRow);
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement