Pattern-1:
output:
1121
12321
1234321
123454321
Code:
int nu = 5;
for (int i = 1; i <= nu; i++)
{
int kk = ((nu-i) +(nu - i)) / 2;
for (int y = 0; y < kk; y++)
{
Console.Write(" ");
}
for (int j = 1; j <= i; j++)
{
Console.Write(j);
}
for (int j = i - 1; j > 0; j--)
{
Console.Write(j);
}
for (int y = 0; y < kk; y++)
{
Console.Write(" ");
}
Console.WriteLine();
}
No comments:
Post a Comment