Advertisement
NikolaySpasovTriset

House

Oct 9th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         int x = 0;
  9.         int y = 0;
  10.         if (n % 2 == 0)
  11.         {
  12.             for (int i = 0; i < n / 2; i++)
  13.             {              
  14.                 Console.Write(new string('-', (n - 2) / 2 - x));
  15.                 Console.Write(new string('*', 2 + y));
  16.                 Console.WriteLine(new string('-', (n - 2) / 2 - x));
  17.                 x += 1;
  18.                 y += 2;
  19.                 if (i == (n / 2) - 1)
  20.                 {
  21.                     for (int j = 0; j < n / 2; j++)
  22.                     {
  23.                         Console.Write("|");
  24.                         Console.Write(new string('*', n - 2));
  25.                         Console.WriteLine("|");
  26.                     }
  27.                 }
  28.                
  29.             }
  30.         }
  31.         else
  32.         {
  33.             for (int i = 0; i < (n / 2) + 1; i++)
  34.             {
  35.                 Console.Write(new string('-', (n - 1) / 2 - x));
  36.                 Console.Write(new string('*', 1 + y));
  37.                 Console.WriteLine(new string('-', (n - 1) / 2 - x));
  38.                 x += 1;
  39.                 y += 2;
  40.                 if (i == (n / 2))
  41.                 {
  42.                     for (int j = 0; j < n / 2; j++)
  43.                     {
  44.                         Console.Write("|");
  45.                         Console.Write(new string('*', n - 2));
  46.                         Console.WriteLine("|");
  47.                     }
  48.                 }
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement