Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LiveDemo
- {
- class Program
- {
- static void Main(string[] args)
- {
- int size = int.Parse(Console.ReadLine());
- char asterisk = '*';
- char whiteSpace = ' ';
- char forwardSlash = '/';
- char pipe = '|';
- char dash = '-';
- int countOfAsterisk = 1;
- if (size % 2 == 0)
- {
- countOfAsterisk = 2;
- }
- int countOfDashes = (size - countOfAsterisk) / 2;
- string topAndBotRow = string.Format("{0}{1}{0}", new string(dash, countOfDashes),
- new string(asterisk, countOfAsterisk));
- Console.WriteLine(topAndBotRow);
- int totalRows = size;
- if (size % 2 == 0)
- {
- size--;
- }
- int rowsOfTopPart = (totalRows - 1) / 2;
- int countOfMiddleDashes = countOfAsterisk;
- for (int currentRow = 0; currentRow < rowsOfTopPart; currentRow++)
- {
- countOfDashes--;
- string sideDashes = new string(dash, countOfDashes);
- string middleDashes = new string(dash, countOfMiddleDashes);
- countOfMiddleDashes += 2;
- Console.WriteLine("{0}*{1}*{0}", sideDashes, middleDashes);
- }
- int rowsOfBottomPart = rowsOfTopPart - 1;
- countOfMiddleDashes -= 4;
- for (int currentRow = 1; currentRow <= rowsOfBottomPart; currentRow++)
- {
- string sideDashes = new string(dash, currentRow);
- string middleDashes = new string(dash, countOfMiddleDashes);
- countOfMiddleDashes -= 2;
- Console.WriteLine("{0}*{1}*{0}", sideDashes, middleDashes);
- }
- if (size > 2)
- {
- Console.WriteLine(topAndBotRow);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment