CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrintingTriangle
{
public class PrintingTriangle
{
public static void Main(string[] args)
{
int num = int.Parse(Console.ReadLine());
PrintLine(1, num);
}
private static void PrintLine(int counter, int num)
{
counter = 1;
for (int cow = 1; cow <= num; cow++)
{
for (int row = 1; row <= counter; row++)
{
Console.Write(row + " ");
}
Console.WriteLine();
counter++;
}
for (int cow = 1; cow <= num; cow++)
{
for (int row = 1; row <= counter - 2; row++)
{
Console.Write(row + " ");
}
Console.WriteLine();
counter--;
}
}
}
}