private static void PrintLineLeft(string value, int screenWidth) {
Console.WriteLine(value);
private static void PrintLineRight(string value, int screenWidth) {
if (value.Length >= screenWidth)
Console.WriteLine(value);
Console.WriteLine($"{new string(' ', screenWidth - value.Length)}{value}");
private static void PrintLineCenter(string value, int screenWidth) {
if (value.Length >= screenWidth)
Console.WriteLine(value);
Console.WriteLine($"{new string(' ', (screenWidth - value.Length) / 2)}{value}");
public static void Main()
for (var i = 1; i <= n; i += 2)
PrintLineCenter(new string('*', i), n);
for (var i = n - 2; i >= 1; i -= 2)
PrintLineCenter(new string('*', i), n);