Skip to content

Instantly share code, notes, and snippets.

@sguzunov
Last active February 18, 2018 12:13
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/d0104b97150f59f80ad870b31d66e72d to your computer and use it in GitHub Desktop.
Save sguzunov/d0104b97150f59f80ad870b31d66e72d to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// https://judge.softuni.bg/Contests/Practice/Index/179#4
namespace DrawButterfly
{
public class Program
{
public static void Main()
{
int n = int.Parse(Console.ReadLine());
int sideWidth = n - 1;
int halfPartHeight = n - 2;
// Drawing first part
for (int rowIndex = 0; rowIndex < halfPartHeight; rowIndex++)
{
char symbol = '*';
if (rowIndex % 2 != 0)
{
symbol = '-';
}
// Left side
string rowOutput = "";
for (int i = 0; i < sideWidth - 1; i++)
{
rowOutput += symbol;
}
rowOutput += "\\ /";
// Right side
for (int i = 0; i < sideWidth - 1; i++)
{
rowOutput += symbol;
}
// Draw row string
Console.WriteLine(rowOutput);
}
// Draw middle row
string middleRow = "@";
for (int i = 0; i < sideWidth; i++)
{
middleRow = " " + middleRow;
}
for (int i = 0; i < sideWidth; i++)
{
middleRow = middleRow + " ";
}
// Draw middle row
Console.WriteLine(middleRow);
// Drawing second part
for (int rowIndex = 0; rowIndex < halfPartHeight; rowIndex++)
{
char symbol = '*';
if (rowIndex % 2 != 0)
{
symbol = '-';
}
// Left side
string rowOutput = "";
for (int i = 0; i < sideWidth - 1; i++)
{
rowOutput += symbol;
}
rowOutput += "/ \\";
// Right side
for (int i = 0; i < sideWidth - 1; i++)
{
rowOutput += symbol;
}
// Draw row string
Console.WriteLine(rowOutput);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment