fbinnzhivko

03.03 Wine Glass

Apr 17th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. class WineGlass
  3. {
  4.     const char GlassFillingSymbol = '*';
  5.     const char EmptySpaceSymbol = '.';
  6.  
  7.     static void Main()
  8.     {
  9.         // Read a positive, even number
  10.         int n = int.Parse(Console.ReadLine());
  11.         int borderSpacing = 0;
  12.         int middleSpacing = n - 2;
  13.  
  14.         for (int i = 0; i < n; i++)
  15.         {
  16.             // For the first half we print the upper part (bowl) of the glass
  17.             if (i < n / 2)
  18.             {
  19.                 string dots = new string(EmptySpaceSymbol, borderSpacing);
  20.                 string asterisks = new string(GlassFillingSymbol, middleSpacing);
  21.                 Console.WriteLine(dots + '\\' + asterisks + '/' + dots);
  22.                 borderSpacing++;
  23.                 middleSpacing -= 2;
  24.             }
  25.             // After that we print the stem according to the rules
  26.             else if (n < 12 && i < n - 1 || n >= 12 && i < n - 2)
  27.             {
  28.                 string dots = new string(EmptySpaceSymbol, n / 2 - 1);
  29.                 Console.WriteLine(dots + '|' + '|' + dots);
  30.             }
  31.             // Finally we print the foot of the glass
  32.             else
  33.             {
  34.                 Console.WriteLine(new string('-', n));
  35.             }
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment