LardaX

Diamond

Jul 20th, 2016
225
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 Diamond
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int size = int.Parse(Console.ReadLine());
  14.             int slash = 0;
  15.             int halfSize = (size - 1) / 2;
  16.             int star = 0;
  17.  
  18.             if (size % 2 == 0)
  19.             {
  20.                 star = 2;
  21.                 slash = 2;
  22.             }
  23.             else
  24.             {
  25.                 star = 1;
  26.                 slash = 1;
  27.             }
  28.  
  29.             Console.WriteLine("{0}{1}{0}", new string('-', (size - 1) / 2), new string('*', star));
  30.  
  31.  
  32.             for (int i = 0; i < halfSize; i++)
  33.             {
  34.                 Console.WriteLine("{0}*{1}*{0}", new string('-', (size - 2 - slash) / 2), new string('-', slash ));
  35.                 slash += 2;
  36.             }
  37.  
  38.             slash = size - 4;
  39.  
  40.             for (int i = halfSize - 1; i > 0; i--)
  41.             {
  42.                 Console.WriteLine("{0}*{1}*{0}", new string('-', (size - 2 - slash) / 2), new string('-', slash));
  43.                 slash -= 2;
  44.             }
  45.  
  46.             if (size > 2)
  47.             {
  48.                 Console.WriteLine("{0}{1}{0}", new string('-', (size - 1) / 2), new string('*', star));
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment