class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the row number");
int n = int.Parse(Console.ReadLine());
for (int row = 0;
row < n; row++)
{
for (int coll =
0; coll < n; coll++)
{
if (row == 0 && (coll >= n
/ 5 && coll <= n / 2 - n / 5) || row == 0 && (coll >= n /
2 + n / 5 && coll <= (n - 1) - n / 5))
{
Console.Write("*" + " ");
}
else if (row > 0 && row <= n / 5 && (coll == n / 5
- row || coll == n / 2 + n / 5 - row || coll == n / 2 - n / 5 + row || coll ==
(n - 1) - n / 5 + row))
{
Console.Write("*" + " ");
}
else if ((row > n / 5 && row <= n / 2) && (coll ==
0 || coll == n - 1))
{
Console.Write("*" + " ");
}
else if (row > n / 2 && (coll == row - n / 2 || coll == (n -
1) - (row - n / 2)))
{
Console.Write("*" + " ");
}
else
{
Console.Write(" ");
}
}
Console.WriteLine();
}
Console.ReadLine();
}
}
No comments:
Post a Comment