Advertisement
dbunalov

05.Diamond

Jul 21st, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.Diamond
  4. {
  5.     class Diamond
  6.     {
  7.         static void Main()
  8.         {
  9.             var n = int.Parse(Console.ReadLine());
  10.             if (n < 4) n = 4;
  11.  
  12.             string firstLine = String.Format("{0}{1}{0}", new string('.', n), new string('*', 3 * n));
  13.             Console.WriteLine(firstLine);
  14.  
  15.             int rows = n;
  16.             int addA = 0;
  17.             int addB = n-4;
  18.             for (int i = 1; i < n; i++)
  19.             {
  20.                 string nextLine = String.Format("{0}*{1}*{0}", new string('.', n - i), new string('.', 3 * n + addA));
  21.                 Console.WriteLine(nextLine);
  22.                 addA += 2;
  23.             }
  24.             string starsLine = String.Format(new string('*', 5 * n));
  25.             Console.WriteLine(starsLine);
  26.  
  27.             for (int j = 2 * n; j >= 1; j--)
  28.             {
  29.                 addB--;
  30.                 string nextLines = String.Format("{0}*{1}*{0}", new string('.', 2 * n - j+1), new string('.', 2 * j + addB + 1));
  31.                 Console.WriteLine(nextLines);
  32.                 addB++;
  33.             }
  34.  
  35.             if (n >= 3)
  36.                 Console.WriteLine("{0}{1}{0}", new string('.', 2 * n + 1), new string('*', n - 2));
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement