Advertisement
DidiMilikina

Hourglass

Apr 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Problem_05___Hourglass
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var n = int.Parse(Console.ReadLine());
  14.             var width = 2 * n + 1;
  15.  
  16.             Console.WriteLine(new string('*',width));
  17.  
  18.             Console.Write(".");
  19.             Console.Write("*");
  20.             Console.Write(new string(' ', width - 4));
  21.             Console.Write("*");
  22.             Console.WriteLine(".");
  23.             var points = 2;
  24.            
  25.             for (int i = 0; i < n - 2; i++)
  26.             {
  27.                 var sharps = width - points * 2 - 2;
  28.                 Console.Write(new string('.', points));
  29.                 Console.Write('*');
  30.                 Console.Write(new string('@',sharps));
  31.                 Console.Write('*');
  32.                 Console.WriteLine(new string('.', points));
  33.                 points += 1;
  34.                
  35.             }
  36.  
  37.             Console.Write(new string('.', n));
  38.             Console.Write('*');
  39.             Console.WriteLine(new string('.', n));
  40.  
  41.             points -= 1;
  42.             for (int i = n - 3; i >= 0; i--)
  43.             {
  44.                 var whiteSpaces = (width - 2 * points - 3) / 2;
  45.                 Console.Write(new string('.', points));
  46.                 Console.Write('*');
  47.                 Console.Write(new string(' ', whiteSpaces));
  48.                 Console.Write("@");
  49.                 Console.Write(new string(' ', whiteSpaces));
  50.                 Console.Write('*');
  51.                 Console.WriteLine(new string('.', points));
  52.                 points -= 1;
  53.             }
  54.             Console.Write('.');
  55.             Console.Write('*');
  56.             Console.Write(new string('@', width - 4));
  57.             Console.Write('*');
  58.             Console.WriteLine('.');
  59.             Console.WriteLine(new string('*', width));
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement