using System;
public class Test
{
public static void Main()
{
var no = Console.ReadLine();
int n = Convert.ToInt32(no);
Pattern print = new Pattern();
print.Pyramid(n);
}
}
public class Pattern
{
public void Pyramid(int n)
{
int m = n*2;
int left = n;
int right = n;
int dummy=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(j<left || j>right)
{
Console.Write(" ");
}
else
{
if(j==left && i!=n)
{
Console.Write("1");
}
else if(j==right && i!=n)
{
Console.Write(i);
}
else if(i==n && dummy<=n)
{
Console.Write("{0} ",dummy);
dummy++;
}
else
{
Console.Write(" ");
}
}
}
left--;
right++;
Console.WriteLine();
}
}
}
public class Test
{
public static void Main()
{
var no = Console.ReadLine();
int n = Convert.ToInt32(no);
Pattern print = new Pattern();
print.Pyramid(n);
}
}
public class Pattern
{
public void Pyramid(int n)
{
int m = n*2;
int left = n;
int right = n;
int dummy=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(j<left || j>right)
{
Console.Write(" ");
}
else
{
if(j==left && i!=n)
{
Console.Write("1");
}
else if(j==right && i!=n)
{
Console.Write(i);
}
else if(i==n && dummy<=n)
{
Console.Write("{0} ",dummy);
dummy++;
}
else
{
Console.Write(" ");
}
}
}
left--;
right++;
Console.WriteLine();
}
}
}
INPUT :
5
OUTPUT:
1 1 2 1 3 1 4 1 2 3 4 5
Comments
Post a Comment