Enter the number: 5
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
class Program
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
class Program
{
static void Main(string[] args)
{
int n, A, B = 0;
Console.WriteLine("enter no of rows u want ");
n = int.Parse(Console.ReadLine());
A = n * 2 - 1;
B = n;
for (int row = 1; row <= A; row++)
{
for (int coll = 1; coll <= A; coll++)
{
if (row <= n)
{
if (coll <= row)
{
Console.Write("*");
}
else
{
if (coll < (n * 2 - row))
{
Console.Write(" ");
}
else
{
Console.Write("*");
}
}
}
else
{
if (coll <= B + 3)
{
Console.Write("*");
B--;
}
else
{
if (row - coll > 0)
{
Console.Write(" ");
}
else
{
Console.Write("*");
}
}
}
}
Console.WriteLine();
}
Console.ReadLine();
}
}
No comments:
Post a Comment