Advertisement
dimipan80

Exam 5. House

Jun 15th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.40 KB | None | 0 0
  1. namespace _3.House
  2. {
  3.     using System;
  4.  
  5.     public class House
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             checked
  10.             {
  11.                 int numN = int.Parse(Console.ReadLine());
  12.                 int lenghtExtDotSeq;
  13.                 int lenghtIntDotSeq;                
  14.                 for (int row = 0; row < numN; row++)
  15.                 {
  16.                     // Printing the Roof of House:
  17.                     if (row == 0)
  18.                     {
  19.                         string dotStr = new string('.', numN / 2);
  20.                         Console.WriteLine("{0}{1}{0}", dotStr, '*');
  21.                     }
  22.                     else if (row == numN / 2)
  23.                     {
  24.                         Console.WriteLine(new string('*', numN));
  25.                     }
  26.                     else if (row < numN / 2)
  27.                     {
  28.                         lenghtExtDotSeq = (numN / 2) - row;
  29.                         string externalDotSeq = new string('.', lenghtExtDotSeq);
  30.                         lenghtIntDotSeq = numN - (2 * lenghtExtDotSeq) - 2;
  31.                         string internalDotSeq = new string('.', lenghtIntDotSeq);
  32.                         Console.WriteLine("{0}{1}{2}{1}{0}", externalDotSeq, '*', internalDotSeq);
  33.                     }                    
  34.                     else if (row == numN - 1)
  35.                     {
  36.                         // Printing the Floor of House:
  37.                         lenghtExtDotSeq = numN / 4;
  38.                         string externalDotSeq = new string('.', lenghtExtDotSeq);
  39.                         lenghtIntDotSeq = numN - (2 * lenghtExtDotSeq) - 2;
  40.                         string intBottomSeq = new string('*', numN - (2 * lenghtExtDotSeq));
  41.                         Console.WriteLine("{0}{1}{0}", externalDotSeq, intBottomSeq);
  42.                     }
  43.                     else if (row > numN / 2 && row + 1 < numN)
  44.                     {
  45.                         lenghtExtDotSeq = numN / 4;
  46.                         string externalDotSeq = new string('.', lenghtExtDotSeq);
  47.                         lenghtIntDotSeq = numN - (2 * lenghtExtDotSeq) - 2;
  48.                         string internalDotSeq = new string('.', lenghtIntDotSeq);
  49.                         Console.WriteLine("{0}{1}{2}{1}{0}", externalDotSeq, '*', internalDotSeq);
  50.                     }
  51.                 }              
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement