Skip to content

Instantly share code, notes, and snippets.

@sguzunov
Created April 22, 2016 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sguzunov/d2acfbb87c928cbf9cb52f945ac4987b to your computer and use it in GitHub Desktop.
Save sguzunov/d2acfbb87c928cbf9cb52f945ac4987b to your computer and use it in GitHub Desktop.
using System;
class Program
{
private const char SpaceSign = ' ';
private const char DotSign = '.';
private const char XSign = 'X';
private const char SlashSign = '/';
private const char BackSlashSign = '\\';
private const char HashTagSign = '#';
static void Main()
{
int n = int.Parse(Console.ReadLine());
int d = int.Parse(Console.ReadLine());
DrawTopPart(n, d);
DrawMiddleLine(n);
DrawBottomPart(n, d);
}
private static void DrawBottomPart(int n, int d)
{
int width = 2 * n + 1;
int spaceCount = 1;
int hashCount = n - 1;
for (int i = 0; i < n; i++)
{
Console.Write(new string(HashTagSign, hashCount));
Console.Write(SlashSign);
int dotCount = width - 4 - (2 * hashCount) - 2 * d;
if (dotCount > 0)
{
Console.Write(new string(SpaceSign, d));
Console.Write(SlashSign);
Console.Write(new string(DotSign, dotCount));
Console.Write(BackSlashSign);
Console.Write(new string(SpaceSign, d));
}
else
{
Console.Write(new string(SpaceSign, spaceCount));
}
Console.Write(BackSlashSign);
Console.WriteLine(new string(HashTagSign, hashCount));
spaceCount += 2;
hashCount--;
}
}
private static void DrawTopPart(int n, int d)
{
int width = 2 * n + 1;
int dotCount = width - 4 - (2 * d);
int spaceCount = width - 2;
for (int i = 0; i < n; i++)
{
Console.Write(new string(HashTagSign, i));
Console.Write(BackSlashSign);
if (dotCount > 0)
{
Console.Write(new string(SpaceSign, d));
Console.Write(BackSlashSign);
Console.Write(new string(DotSign, dotCount));
Console.Write(SlashSign);
Console.Write(new string(SpaceSign, d));
}
else
{
Console.Write(new string(SpaceSign, spaceCount));
}
Console.Write(SlashSign);
Console.WriteLine(new string(HashTagSign, i));
spaceCount -= 2;
dotCount -= 2;
}
}
private static void DrawMiddleLine(int n)
{
Console.Write(new string(HashTagSign, n));
Console.Write(XSign);
Console.WriteLine(new string(HashTagSign, n));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment