ad2bg

Untitled

Nov 24th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. namespace ChristmasHat
  2. {
  3.     using System;
  4.  
  5.     static class ChristmasHat
  6.     {
  7.         static void Main()
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             Console.WriteLine('.'.Times(2 * n - 1) + @"/|\" + '.'.Times(2 * n - 1));
  12.             Console.WriteLine('.'.Times(2 * n - 1) + @"\|/" + '.'.Times(2 * n - 1));
  13.  
  14.             for (int i = 0; i < 2 * n; i++)
  15.             {
  16.                 Console.WriteLine(
  17.                     '.'.Times(2 * n - i - 1) +
  18.                     '*' + '-'.Times(i) +
  19.                     '*' + '-'.Times(i) +
  20.                     '*' +
  21.                     '.'.Times(2 * n - i - 1));
  22.             }
  23.  
  24.             Console.WriteLine('*'.Times(4 * n + 1));
  25.             Console.WriteLine("*" + ".*".Times(2 * n));
  26.             Console.WriteLine('*'.Times(4 * n + 1));
  27.         }
  28.  
  29.         static string Times(this char c, int x) => x <= 0 ? String.Empty : new string(c, x);
  30.  
  31.         static string Times(this string s, int x)
  32.         {
  33.             string newString = string.Empty;
  34.             for (int i = 0; i < x; i++) { newString += s; }
  35.             return newString;
  36.         }      
  37.     }
  38. }
Add Comment
Please, Sign In to add comment