using System;
public class Test
{
public static void Main()
{
var no = Console.ReadLine();
int n = Convert.ToInt32(no);
Pattern print = new Pattern();
//declaration
print.HollowDiamond(n);
}
}
//definition
public class Pattern
{
public void HollowDiamond(int n)
{
int lefttriangle = n;
int righttriangle=lefttriangle;
int dummy=n;
int m = n*2;
for(int i=0;i<m;i++)
{
for(int j=0;j<m;j++)
{
if(j==lefttriangle || j==righttriangle)
{
Console.Write("*");
}
else
{
Console.Write(" ");
}
}
if(i<n-1)
{
lefttriangle--;
righttriangle++;
}
else if(i==(n-1))
{
lefttriangle=lefttriangle ;
righttriangle=righttriangle;
}
else
{
lefttriangle++;
righttriangle--;
}
Console.WriteLine();
}
}
}
OUTPUT
* * * * * * * * * * * * * * * * * *
Comments
Post a Comment