Skip to content

Instantly share code, notes, and snippets.

@ktopchiev
Last active November 29, 2017 23:18
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 ktopchiev/2b72cc75f89e0cb5a882e5488509d124 to your computer and use it in GitHub Desktop.
Save ktopchiev/2b72cc75f89e0cb5a882e5488509d124 to your computer and use it in GitHub Desktop.
Рисуване на снежинка със C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Snowflake
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
var dots = 1;
var dots2 = 1;
//Рисуване на горната част
Console.WriteLine("*" + new string('.', n) + "*" + new string('.', n) + "*");
for (int up = 0; up < n; up++)
{
dots2 = n - dots;
Console.WriteLine(new string('.', dots) + "*" + new string('.', dots2) + "*" + new string('.', dots2) + "*" + new string('.', dots));
dots++;
if (dots == n - 1)
{
Console.WriteLine(new string('.', n - 1) + "*****" + new string ('.', n - 1));
break;
}
}
//Рисуване на средната част
Console.WriteLine(new string('*', 2 * n + 3));
//Рисуване на долната част
Console.WriteLine(new string('.', n - 1) + "*****" + new string('.', n - 1));
for (int down = 0; down < n - 1; down++)
{
dots2 = n - dots + 1;
Console.WriteLine(new string('.', dots - 1) + "*" + new string('.', dots2) + "*" + new string('.', dots2) + "*" + new string('.', dots - 1));
dots--;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment