using System;Output :
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pattern1
{
class Program
{
static void Main(String[] args)
{
int n, k, no;
Console.WriteLine("Enter value");
n = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
k = 0;
no = n - 2;
for (int j = 1; j <= i; j++)
{
if (j == 1)
{
Console.Write(i);
}
else if (j == 2)
{
k = k + i + (n - (j - 1));
Console.Write(" " + k);
}
else
{
k = k + no;
Console.Write(" " + k);
no--;
}
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
}
Tags:
csharp.net