Advertisement
dimipan80

Task4_DiamondTrolls

Apr 7th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using System.Threading;
  4.  
  5. class DiamondTrolls
  6. {
  7.     static void Main()
  8.     {
  9.         Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  10.         checked
  11.         {
  12.             byte numN = byte.Parse(Console.ReadLine());
  13.             int countLines = ((numN - 3) / 2) * 3 + 6;
  14.             int elemOnLine = numN * 2 + 1;
  15.             int halfLines = elemOnLine / 2 + 1;
  16.             int horizLine = countLines - numN;
  17.             for (int row = 1; row <= countLines; row++)
  18.             {
  19.                 for (int col = 1; col <= elemOnLine; col++)
  20.                 {
  21.                     if (row == horizLine || col == halfLines)
  22.                     {
  23.                         Console.Write("*");
  24.                     }
  25.                     else if ((row == 1 && col >= (halfLines - numN / 2) && col <= (halfLines + numN / 2))
  26.                         || col == (halfLines - numN / 2 - row + 1) || col == (numN + numN / 2 + row))
  27.                     {
  28.                         Console.Write("*");
  29.                     }
  30.                     else if (row >= horizLine && (col == row + 1 - horizLine || col == halfLines + countLines - row))
  31.                     {
  32.                         Console.Write("*");
  33.                     }
  34.                     else
  35.                     {
  36.                         Console.Write(".");
  37.                     }
  38.                 }
  39.                 Console.WriteLine();
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement