LusienGG

[C#] House of stars

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