Advertisement
striking

Diamond

Dec 7th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1.  
  2.  
  3.  
  4. using System;
  5. class DiamondTrolls
  6. {
  7.     static void Main()
  8.     {
  9.         int N = int.Parse(Console.ReadLine());
  10.         int width = (N * 2) + 1;
  11.         int height = (6 + ((N - 3) / 2) * 3);
  12.         int widthDiamond = N;
  13.         int dot = ((width - N) / 2) - 1; // dobavqmi - i
  14.         int dotTwo = ((width - N) / 2);
  15.         int heightFirstPart = (height / 3) - 1;
  16.        
  17.         //firstPart
  18.         Console.Write(new string('.', dotTwo));
  19.         Console.Write(new string('*', N));
  20.         Console.WriteLine(new string ('.', dotTwo));
  21.        
  22.         for (int i = 0; i < heightFirstPart; i++)
  23.         {
  24.             Console.Write(new string ('.', dot - i));
  25.             Console.Write("*");
  26.             Console.Write(new string ('.', dot + i));
  27.             Console.Write("*");
  28.             Console.Write(new string ('.', dot + i));
  29.             Console.Write("*");
  30.             Console.WriteLine(new string ('.', dot - i));
  31.         }
  32.  
  33.         Console.WriteLine(new string ('*', width));
  34.  
  35.         //secondPart
  36.  
  37.         int dotSecondPart = (width - 5) / 2;
  38.         for (int i = 0; i < N - 1; i++)
  39.         {
  40.             Console.Write(new string ('.', 1 + i));
  41.             Console.Write("*");
  42.             Console.Write(new string ('.', dotSecondPart - i));
  43.             Console.Write("*");
  44.             Console.Write(new string('.', dotSecondPart - i));
  45.             Console.Write("*");
  46.             Console.WriteLine(new string('.', 1 + i));
  47.         }
  48.  
  49.         Console.Write(new string ('.', (width - 1) / 2));
  50.         Console.Write("*");
  51.         Console.WriteLine(new string('.', (width - 1) / 2));
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement