Advertisement
simonradev

Axe

Aug 19th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.39 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 FifthExcercise
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int size = int.Parse(Console.ReadLine());
  14.  
  15.             string singleRowToFormat = "{0}*{1}*{2}";
  16.  
  17.             char dash = '-';
  18.             char asterisk = '*';
  19.  
  20.             int figureWidth = size * 5;
  21.  
  22.             int countOfLeftSymbols = size * 3;
  23.             int countOfMiddleSymbols = 0;
  24.             int countOfRightSymbols = figureWidth - (countOfLeftSymbols + 2);
  25.  
  26.             string leftPart = string.Empty;
  27.             string middlePart = string.Empty;
  28.             string rightPart = string.Empty;
  29.  
  30.             // first part
  31.             for (int currentRow = 0; currentRow < size; currentRow++)
  32.             {
  33.                 leftPart = new string(dash, countOfLeftSymbols);
  34.                 middlePart = new string(dash, currentRow);
  35.                 rightPart = new string(dash, countOfRightSymbols--);
  36.  
  37.                 countOfMiddleSymbols = currentRow;
  38.  
  39.                 Console.WriteLine(singleRowToFormat, leftPart, middlePart, rightPart);
  40.             }
  41.  
  42.             int middleAndBottomPartRows = size / 2;
  43.  
  44.             // second part
  45.             countOfRightSymbols = countOfMiddleSymbols;
  46.             for (int currentRow = 0; currentRow < middleAndBottomPartRows; currentRow++)
  47.             {
  48.                 leftPart = new string(asterisk, countOfLeftSymbols);
  49.                 middlePart = new string(dash, countOfMiddleSymbols);
  50.                 rightPart = new string(dash, countOfRightSymbols);
  51.                
  52.                 Console.WriteLine(singleRowToFormat, leftPart, middlePart, rightPart);
  53.             }
  54.  
  55.             // bottom part
  56.             for (int currentRow = 1; currentRow <= middleAndBottomPartRows; currentRow++)
  57.             {
  58.                 char middleSymbol = currentRow == middleAndBottomPartRows ? asterisk : dash;
  59.  
  60.                 leftPart = new string(dash, countOfLeftSymbols--);
  61.                 middlePart = new string(middleSymbol, countOfMiddleSymbols);
  62.                 rightPart = new string(dash, countOfRightSymbols--);
  63.                
  64.                 countOfMiddleSymbols += 2;
  65.  
  66.                 Console.WriteLine(singleRowToFormat, leftPart, middlePart, rightPart);
  67.             }
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement