Enter the number:5
1 2 3 4 5
4 3 2 1
1 2 3
2 1
1
class Program
{
static void Main(string[] args)
{
int temp;
Console.WriteLine("Enter the number");
int n = int.Parse(Console.ReadLine());
for(int row=5;row>=1;row--)
{
if (row % 2 == 1)
temp = 1;
else
temp = row;
for (int coll = 1; coll <= row; coll++)
{
Console.Write(temp);
if (row % 2 == 1)
temp++;
else
temp--;
}
Console.WriteLine();
}
Console.ReadLine();
}
}
1 2 3 4 5
4 3 2 1
1 2 3
2 1
1
class Program
{
static void Main(string[] args)
{
int temp;
Console.WriteLine("Enter the number");
int n = int.Parse(Console.ReadLine());
for(int row=5;row>=1;row--)
{
if (row % 2 == 1)
temp = 1;
else
temp = row;
for (int coll = 1; coll <= row; coll++)
{
Console.Write(temp);
if (row % 2 == 1)
temp++;
else
temp--;
}
Console.WriteLine();
}
Console.ReadLine();
}
}
No comments:
Post a Comment