Advertisement
Guest User

Sandglass

a guest
Mar 5th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using System;
  2.  
  3. class Sandglass
  4. {
  5.     static void Main()
  6.     {
  7.         int size = int.Parse(Console.ReadLine());
  8.  
  9.         int outerDots = 0;
  10.         int innerAsterisks = size;
  11.  
  12.         for (int i = 0; i < size; i++)
  13.         {
  14.             Console.WriteLine(
  15.                 "{0}{1}{0}",
  16.                 new string('.', outerDots),
  17.                 new string('*', innerAsterisks));
  18.  
  19.             if (i >= size / 2)
  20.             {
  21.                 outerDots--;
  22.                 innerAsterisks += 2;
  23.             }
  24.             else
  25.             {
  26.                 outerDots++;
  27.                 innerAsterisks -= 2;
  28.             }
  29.         }      
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement