iliya87

03.DrawHouseWithWindow

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