Advertisement
JOHNYTHEWINNER

Sunglasses-just a simple solution

Apr 9th, 2015
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         // input
  8.         int N = int.Parse(Console.ReadLine());
  9.  
  10.         // logic
  11.         string upFrames = new String('*', 2 * N); // This we will use for first and last rows of the frames.
  12.         string betweenFrames = new String(' ', N); // This we will use for empty space between frames.
  13.         string bridge = new String('|', N);  // This we will use for bridge between frames.
  14.         string lenses = new String('/', (2 * N) - 2);  //This we will use for lense.
  15.         int counter = 0; // This counter we will use for vertical draw
  16.  
  17.         // printing
  18.         do
  19.         {
  20.             if (counter == 0 || counter == N - 1)
  21.             {
  22.                 Console.WriteLine("{0}{1}{0}", upFrames, betweenFrames); //Here we print frames and spaces for first and last rows only.
  23.             }
  24.               else if (counter == N/2)
  25.             {
  26.                 Console.WriteLine("*{0}*{1}*{0}*", lenses, bridge); //Here we print bridge. This is exactly the middle of sunglasses.
  27.             }
  28.            
  29.            else
  30.             {
  31.                 Console.WriteLine("*{0}*{1}*{0}*", lenses, betweenFrames); // Here we print frames and lenses for all rows without first and last.
  32.             }
  33.             counter++;
  34.         } while (counter != N); //Here we finish our loop because we are at end position (N rows are drawn).
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement