Advertisement
dimipan80

Exam 7. Wine Glass

Jun 20th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using System.Threading;
  4.  
  5. public class PrintWineGlass
  6. {
  7.     public static void Main()
  8.     {
  9.         Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  10.         checked
  11.         {
  12.             int length = int.Parse(Console.ReadLine());
  13.  
  14.             int asteriskSeqWidth = length - 2;
  15.             string asteriskSequence;
  16.             int dotSeqWidth = 0;
  17.             string outerDotSequence;
  18.             string hyphenSequence = new string('-', length);
  19.             for (int row = 0; row < length; row++)
  20.             {
  21.                 if (row < length / 2)
  22.                 {
  23.                     asteriskSequence = new string('*', asteriskSeqWidth);
  24.                     outerDotSequence = new string('.', dotSeqWidth);
  25.                     Console.WriteLine("{0}\\{1}/{0}", outerDotSequence, asteriskSequence);
  26.                     dotSeqWidth++;
  27.                     asteriskSeqWidth -= 2;
  28.                 }
  29.                 else if (row == length - 1 || (length >= 12 && row == length - 2))
  30.                 {
  31.                     Console.WriteLine(hyphenSequence);
  32.                 }
  33.                 else
  34.                 {
  35.                     dotSeqWidth = (length / 2) - 1;
  36.                     outerDotSequence = new string('.', dotSeqWidth);
  37.                     Console.WriteLine("{0}||{0}", outerDotSequence);
  38.                 }
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement