Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _17.Sunglasses
- {
- using System;
- public class DrawSunglasses
- {
- public static void Main(string[] args)
- {
- checked
- {
- // Enter and read height of sunglasses, always an odd number:
- byte numN = byte.Parse(Console.ReadLine());
- // Calculating number (width) of Frames:
- byte countFrames = (byte)(2 * numN);
- // Calculating number (width) of Lenses:
- byte countLenses = (byte)(countFrames - 2);
- // Create string for Top or Bottom row Frame:
- string topBottomFrame = new string('*', countFrames);
- // Create string for Whitespace on row between Left and Right Frames:
- string whitespaceBetweenFrames = new string(' ', numN);
- // Create string for Lens on row:
- string lens = new string('/', countLenses);
- lens = '*' + lens + '*';
- // Create string for Bridge between Left and Right Frames on middle row:
- string bridge = new string('|', numN);
- // Print created strings and drawing Sunglasses:
- for (int row = 0; row < numN; row++)
- {
- if (row == 0 || row == numN - 1)
- {
- // Print Frames on Top and Bottom row:
- Console.WriteLine("{0}{1}{0}", topBottomFrame, whitespaceBetweenFrames);
- }
- else if (row == numN / 2)
- {
- // Print Frames and Bridge on middle row:
- Console.WriteLine("{0}{1}{0}", lens, bridge);
- }
- else
- {
- // Print Lenses on other rows:
- Console.WriteLine("{0}{1}{0}", lens, whitespaceBetweenFrames);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement