simonradev

Diamond

Mar 12th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 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 Diamond
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int size = int.Parse(Console.ReadLine());
  14.  
  15.             //printing the top part
  16.             int sideDots = size;
  17.             int middleSymbol = (3 * size) - 2;
  18.             for (int currRow = 0; currRow < size; currRow++)
  19.             {
  20.                 char symbolToUse = currRow == 0 ? '*' : '.';
  21.  
  22.                 Console.Write(new string('.', sideDots - currRow));
  23.                 Console.Write('*');
  24.                 Console.Write(new string(symbolToUse, middleSymbol));
  25.                 Console.Write('*');
  26.                 Console.WriteLine(new string('.', sideDots - currRow));
  27.  
  28.                 middleSymbol += 2;
  29.             }
  30.  
  31.             //printing the mid row
  32.             Console.WriteLine(new string('*', size * 5));
  33.  
  34.             //printing the bot row
  35.             int botRows = ((size * 3) + 2) - (size + 1);
  36.  
  37.             for (int currRow = 1; currRow <= botRows; currRow++)
  38.             {
  39.                 char symbolToUse = currRow == botRows ? '*' : '.';
  40.  
  41.                 middleSymbol -= 2;
  42.  
  43.                 Console.Write(new string('.', currRow));
  44.                 Console.Write('*');
  45.                 Console.Write(new string(symbolToUse, middleSymbol));
  46.                 Console.Write('*');
  47.                 Console.WriteLine(new string('.', currRow));
  48.             }
  49.         }
  50.     }
  51. }
Add Comment
Please, Sign In to add comment