thegrudge

Sunglasses

Nov 13th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. class Sunglasses
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.         for (int i = 1; i <= n; i++)
  8.         {
  9.             //Check the row is it first or last.
  10.             // if it is, we are writing only * for the frames of the sunglasses and a space between the shades.
  11.             if (i == 1 || i==n)  
  12.             {
  13.                 string frameTopBottom = new string('*', n * 2);
  14.                 string spaceBetween = new string(' ', n);
  15.                 Console.WriteLine("{0}{1}{0}",frameTopBottom, spaceBetween);
  16.             }
  17.             else
  18.             {
  19.                 // Here we check is the current row is the one in the middles or not.
  20.                 // If it is, we are writing the bridge between the shades.
  21.                 if (i == (n+1)/2)
  22.                 {
  23.                     string middleFrame = new string('*', 1);
  24.                     string glass = new string('/', (n - 1) * 2);
  25.                     string bridge = new string('|', n);
  26.                     Console.WriteLine("{0}{1}{0}{2}{0}{1}{0}", middleFrame, glass, bridge);
  27.                 }
  28.                 else
  29.                 {
  30.                     string middleFrame = new string('*', 1);
  31.                     string glass = new string('/', (n - 1) * 2);
  32.                     string spaceBetween = new string(' ', n);
  33.                     Console.WriteLine("{0}{1}{0}{2}{0}{1}{0}", middleFrame, glass, spaceBetween);
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment