Advertisement
dimipan80

Exam July Evening 3. House with a Window

Jul 27th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2.  
  3. public class HouseWithAWindow
  4. {
  5.     public static void Main()
  6.     {        
  7.         checked
  8.         {
  9.             int num = int.Parse(Console.ReadLine());
  10.  
  11.             int width = (2 * num) - 1;
  12.             int outerDots = num - 1;
  13.             string outerDotSeq = new string('.', outerDots);
  14.             Console.WriteLine("{0}*{0}", outerDotSeq);
  15.             int innerDots = 1;
  16.             string innerDotSeq;
  17.             for (int row = 1; row < num; row++)
  18.             {
  19.                 outerDots--;
  20.                 outerDotSeq = new string('.', outerDots);
  21.                 innerDotSeq = new string('.', innerDots);
  22.                 Console.WriteLine("{0}*{1}*{0}", outerDotSeq, innerDotSeq);
  23.                 innerDots += 2;
  24.             }
  25.  
  26.             Console.WriteLine(new string('*', width));
  27.  
  28.             innerDotSeq = new string('.', width - 2);
  29.             string innerAsteriskSeq = new string('*', num - 3);
  30.             outerDots = num / 2;
  31.             outerDotSeq = new string('.', outerDots);
  32.             for (int row = 0; row < num; row++)
  33.             {
  34.                 if (row < (num / 4) || row >= (num * 3) / 4)
  35.                 {
  36.                     Console.WriteLine("*{0}*", innerDotSeq);
  37.                 }
  38.                 else
  39.                 {
  40.                     Console.WriteLine("*{0}{1}{0}*", outerDotSeq, innerAsteriskSeq);
  41.                 }
  42.             }
  43.  
  44.             Console.WriteLine(new string('*', width));
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement