Advertisement
DidiMilikina

Hourglass

Apr 19th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 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 Axe
  8. {
  9.     class Axe
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var n = int.Parse(Console.ReadLine());
  14.             var width = 2 * n + 1;
  15.             var points = 2;
  16.  
  17.             Console.WriteLine(new string('*', width));
  18.             Console.WriteLine(".*{0}*.", new string(' ', width - 4));
  19.  
  20.             for (int i = 1; i <= n - 2; i++)
  21.             {
  22.                 Console.WriteLine("{0}*{1}*{0}"
  23.               , new string('.', points)
  24.               , new string('@', width - 4 - 2 * i)
  25.               );
  26.                 points += 1;
  27.             }
  28.  
  29.             Console.WriteLine("{0}*{1}"
  30.                 , new string('.', width / 2)
  31.                 , new string('.', width / 2));
  32.             points -= 1;
  33.  
  34.             for (int i = n - 3; i >= 0; i--)
  35.             {
  36.                 var whiteSpaces = (width - 2 * points - 3) / 2;
  37.                 Console.WriteLine("{0}*{1}@{1}*{0}"
  38.              , new string('.', points)
  39.              , new string(' ', whiteSpaces)
  40.              , ('@')
  41.              );
  42.                 points -= 1;
  43.             }
  44.             Console.WriteLine("{0}*{1}*{0}"
  45.                 ,('.')
  46.                 ,new string('@', width - 4));
  47.             Console.WriteLine(new string('*', width));
  48.  
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement