CSharp · Console
using System;
public class Program
{
public static void Main()
{
Console.WriteLine();
Console.WriteLine("This program will print isosceles triangle!");
Console.WriteLine();
Console.Write("Enter even number for the base a: ");
int a = int.Parse(Console.ReadLine());
int b = a + a + 1;
////int d = 1; // Не се използва никъде
int n = 0;
int c = a + 1;
char emptySpace = ' ';
char symbol = '©';
//if (a % 2 == 0)
//{
for (int y = 0; y <= (a - 2); y++, c++)
{
for (n = a - 1; n >= 0; n--)
{
if ((y < (n + 1)) || (y > (n + 1)))
{
Console.Write(emptySpace);
}
else
{
Console.Write(symbol);
}
}
for (int e = a + 1; e <= b; e++)
{
if ((c < e) || (c > e))
{
Console.Write(emptySpace);
}
else
{
Console.Write(symbol);
}
}
Console.WriteLine();
}
for (int x = 1; x <= b; x++) // base of the triangle
{
if (x % 2 == 0)
{
Console.Write(symbol);
}
else
{
Console.Write(emptySpace);
}
}
Console.WriteLine();
}
//else
//{
// Console.WriteLine();
// Console.WriteLine("Your number it is not correct! Try again!");
// Console.WriteLine();
//}
}