Venciity

[SoftUni C# exam preparation] 03.SandGlass [decision 2]

Apr 10th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2.  
  3. class SandGlass
  4. {
  5.     static void Main()
  6.     {
  7.         int n = Int32.Parse(Console.ReadLine());
  8.         int asterixes = n;
  9.         int dots = 0;
  10.  
  11.         while (true)
  12.         {
  13.             DrawLine(asterixes, dots);
  14.             asterixes = asterixes - 2;
  15.             dots++;
  16.             Console.WriteLine();
  17.             if (asterixes == -1)
  18.             {
  19.                 break;
  20.             }
  21.         }
  22.  
  23.         asterixes = 3;
  24.         dots = (n - asterixes) / 2;
  25.  
  26.         while (true)
  27.         {
  28.             DrawLine(asterixes, dots);
  29.             asterixes = asterixes + 2;
  30.             dots--;
  31.             Console.WriteLine();
  32.             if (dots == -1)
  33.             {
  34.                 break;
  35.             }
  36.         }
  37.     }
  38.  
  39.     private static void DrawLine(int asterixes, int dots)
  40.     {
  41.         for (int i = 0; i < dots; i++)
  42.         {
  43.             Console.Write('.');
  44.         }
  45.         for (int i = 0; i < asterixes; i++)
  46.         {
  47.             Console.Write('*');
  48.         }
  49.         for (int i = 0; i < dots; i++)
  50.         {
  51.             Console.Write('.');
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment