Advertisement
aggressiveviking

09.House

Mar 3rd, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _09.House
  4. {
  5.     class House
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             var stars = 1;
  12.             if (n % 2 == 0)
  13.             {
  14.                 stars++;
  15.             }
  16.  
  17.             var roofLength = (int)Math.Ceiling(n / 2f);
  18.  
  19.             for (int i = 0; i < roofLength; i++)
  20.             {
  21.                 var padding = (n - stars) / 2;
  22.                 var line = new string('-', padding)
  23.                     + new string('*', stars)
  24.                     + new string('-', padding);
  25.                 Console.WriteLine(line);
  26.                 stars += 2;
  27.             }
  28.  
  29.             for (int i = 0; i < n/2; i++)
  30.             {
  31.                 var line = "|" + new string('*', n - 2) + "|";
  32.                 Console.WriteLine(line);
  33.             }
  34.  
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement