Diamond pattern program in c#
Diamond pattern program in c#
Source code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
int n = 9;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
Console.Write("* ");
}
for (int j = 0; j < i; j++) {
Console.Write(" ");
}
for (int j = 0; j < i; j++)
{
Console.Write(" ");
}
for (int j = i; j < n; j++)
{
Console.Write("* ");
}
Console.WriteLine();
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j <= i; j++)
{
Console.Write("* ");
}
for (int j = i; j < n-1; j++)
{
Console.Write(" ");
}
for (int j = i; j < n-1; j++)
{
Console.Write(" ");
}
for (int j = 0; j <= i; j++)
{
Console.Write("* ");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
Comments
Post a Comment