Advertisement
nmnikolov

Sunglasses

Jun 7th, 2014
1,297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. class Sunglasses
  3. {
  4.     static void Main()
  5.     {
  6.         int height = int.Parse(Console.ReadLine());
  7.         string lens = new string('/', 2 * height - 2);
  8.         string bridge = new string('|', height);
  9.         string emptySpace = new string(' ', height);
  10.         string lensAndFrame = string.Format("{0}{1}{0}", '*', lens);
  11.         string frame = new string('*', 2 * height);
  12.  
  13.         for (int i = 0; i < height; i++)
  14.         {          
  15.             if (i == 0 || i == height - 1)  //Print first and last row of the frame
  16.             {                
  17.                 Console.WriteLine("{0}{1}{0}", frame, emptySpace);
  18.             }
  19.             else if (i == height / 2)   //Print midlle frame row + bridge
  20.             {
  21.                 Console.WriteLine("{0}{1}{0}", lensAndFrame, bridge);
  22.             }
  23.             else  //Print all other rows of the frame
  24.             {                              
  25.                 Console.WriteLine("{0}{1}{0}", lensAndFrame, emptySpace);
  26.             }            
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement