Advertisement
fbinnzhivko

Eclipse

May 2nd, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. class Eclipse
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine()); // Sunglasses height        
  7.  
  8.         for (int i = 0; i < n; i++)
  9.         {
  10.             if (i == 0 || i == n - 1)
  11.             {
  12.                 PrintTopBottomPart(n);
  13.             }
  14.             else
  15.             {
  16.                 PrintMiddlePart(n, i);
  17.             }
  18.         }
  19.     }
  20.  
  21.     private static void PrintMiddlePart(int n, int i)
  22.     {
  23.         string lens = new string('/', n * 2 - 2);
  24.         string middleFrame = string.Format("{0}{1}{0}", '*', lens);
  25.         string connection = new string(' ', n - 1); // Default empty space between the two frames
  26.         // Checking if the row we're currently at is the one that the bridge should be on
  27.         if (i == n / 2)
  28.         {
  29.             connection = new string('-', n - 1); // Bridge
  30.         }
  31.         Console.WriteLine("{0}{1}{0}", middleFrame, connection);
  32.     }
  33.  
  34.     private static void PrintTopBottomPart(int n)
  35.     {
  36.         string frame = new string('*', 2 * n - 2);
  37.         string emptySpace = new string(' ', n + 1);
  38.         Console.WriteLine(" {0}{1}{0} ", frame, emptySpace, frame);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement