fbinnzhivko

03.01 House with a Window

Apr 16th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. public class HouseWithWindow
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.  
  8.         int starsBefore = n - 1;
  9.         int starsMiddle = 1;
  10.  
  11.         Console.WriteLine("{0}*{0}", new string('.', starsBefore));
  12.         for (int i = 0; i < n - 1; i++)
  13.         {
  14.             starsBefore--;
  15.             Console.WriteLine("{0}*{1}*{0}",
  16.                 new String('.', starsBefore), new String('.', starsMiddle));
  17.             starsMiddle += 2;
  18.         }
  19.         Console.WriteLine(new string('*', 2 * n - 1));
  20.         for (int i = 0; i < n / 4; i++)
  21.         {
  22.             Console.WriteLine("*{0}*", new string('.', n * 2 - 3));
  23.         }
  24.         int dotsBetweenWindows = n / 2;
  25.         int windowsStars = n - 3;
  26.         for (int i = 0; i < n / 2; i++)
  27.         {
  28.             Console.WriteLine("*{0}{1}{0}*",
  29.                 new string('.', dotsBetweenWindows), new string('*', windowsStars));
  30.         }
  31.         for (int i = 0; i < n / 4; i++)
  32.         {
  33.             Console.WriteLine("*{0}*", new string('.', n * 2 - 3));
  34.         }
  35.         Console.WriteLine(new string('*', 2 * n - 1));
  36.     }
  37. }
Add Comment
Please, Sign In to add comment