Aggrodin

Eclipse

Apr 18th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. class Eclipse
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());        
  8.  
  9.         for (int i = 0; i < n; i++)
  10.         {
  11.             if (i == 0 || i == n - 1)
  12.             {
  13.                 PrintTopBottomPart(n);
  14.             }
  15.             else
  16.             {
  17.                 PrintMiddlePart(n, i);
  18.             }
  19.         }
  20.     }
  21.  
  22.     private static void PrintMiddlePart(int n, int i)
  23.     {
  24.         string lens = new string('/', n * 2 - 2);
  25.         string middleFrame = string.Format("{0}{1}{0}", '*', lens);
  26.         string connection = new string(' ', n-1);
  27.         if (i == n / 2)
  28.         {
  29.             connection = new string('-', n-1);
  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