Advertisement
Niicksana

Diamond

Dec 9th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.30 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.             // Exam - 17 July 2016
  14.             int n = int.Parse(Console.ReadLine());
  15.  
  16.             int dots = n;
  17.             int stars = (5 * n) - ((2 * n) + 2);
  18.  
  19.             for (int first = 1; first <= n ; first++)
  20.             {
  21.                 if (first == 1)
  22.                 {
  23.                     Console.Write(new string('.', dots));
  24.                     Console.Write("*");
  25.                     Console.Write(new string('*', stars));
  26.                     Console.Write("*");
  27.                     Console.WriteLine(new string('.', dots));
  28.                     dots--;
  29.                     stars += 2;
  30.                 }
  31.  
  32.                 else
  33.                 {
  34.                     Console.Write(new string('.', dots));
  35.                     Console.Write("*");
  36.                     Console.Write(new string('.', stars));
  37.                     Console.Write("*");
  38.                     Console.WriteLine(new string('.', dots));
  39.                     dots--;
  40.                     stars += 2;
  41.                 }
  42.             }
  43.             Console.WriteLine(new string('*', 5 * n));
  44.  
  45.             int firstDots = 1;
  46.             int centralDots = (5 * n) - 4;
  47.             for (int second = 1; second <= 2 * n + 1; second++)
  48.             {
  49.                 if (second < 2 * n + 1)
  50.                 {
  51.                     Console.Write(new string('.', firstDots));
  52.                     Console.Write("*");
  53.                     Console.Write(new string('.', centralDots));
  54.                     Console.Write("*");
  55.                     Console.WriteLine(new string('.', firstDots));
  56.                     firstDots++;
  57.                     centralDots -= 2;
  58.                 }
  59.  
  60.                 else
  61.                 {
  62.                     Console.Write(new string('.', firstDots));
  63.                     Console.Write("*");
  64.                     Console.Write(new string('*', centralDots));
  65.                     Console.Write("*");
  66.                     Console.WriteLine(new string('.', firstDots));
  67.                     firstDots++;
  68.                     centralDots -= 2;
  69.                 }
  70.             }
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement