Advertisement
dakata

DrawFort

Oct 16th, 2016
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2.  
  3. namespace DrawFort
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             var input = ushort.Parse(Console.ReadLine());
  10.             var width = (ushort)(input * 2);//Width of the fort
  11.             var numberOfCarets = (ushort)(input / 2);//The number of '^' symbols  in a single sequence
  12.             var numberOfUnderscores = (ushort)(width - (numberOfCarets * 2) - 4);//The number of '_' symbols in a single sequence
  13.  
  14.             var underscores = new string('_', numberOfUnderscores);
  15.             var carets = new string('^', numberOfCarets);
  16.  
  17.             for (ushort row = 0; row < input; row++)
  18.             {
  19.                 if (row == 0) Console.WriteLine(@"/{0}\{1}/{0}\", carets, underscores);
  20.                 else if (row == input - 2) Console.WriteLine(@"|{0}{1}{0}|", new string(' ', (width - numberOfUnderscores - 2) / 2), underscores);
  21.                 else if (row == input - 1) Console.WriteLine(@"\{0}/{1}\{0}/", new string('_', input/2), new string(' ', 2 * (input - numberOfCarets) - 4));
  22.                 else Console.WriteLine("|{0}|", new string(' ', width - 2));
  23.             }
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement