Advertisement
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 = '|';
- string rowToFormat = "*{0}*{1}*{0}*";
- int countOfMiddleSymbols = size * 2 - 2;
- string firstAndLastRow = string.Format(rowToFormat,
- new string(asterisk, countOfMiddleSymbols),
- new string(whiteSpace, size));
- Console.WriteLine(firstAndLastRow);
- int rows = size - 2;
- int rowOfNeshtoSi = (int)(Math.Ceiling(size / 2.0) - 2);
- for (int currentRow = 0; currentRow < rows; currentRow++)
- {
- char currentMiddleSymbol = whiteSpace;
- if (currentRow == rowOfNeshtoSi)
- {
- currentMiddleSymbol = pipe;
- }
- string formattedRow = string.Format(rowToFormat,
- new string(forwardSlash, countOfMiddleSymbols),
- new string(currentMiddleSymbol, size));
- Console.WriteLine(formattedRow);
- }
- Console.WriteLine(firstAndLastRow);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement