Advertisement
Qrist

Printing Triangle

Apr 15th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     public static void Main(string[] args)
  6.     {
  7.         int n2 = int.Parse(Console.ReadLine());      
  8.         Triangle(n2);
  9.     }
  10.     public static void PrintLine(int a,int b)
  11.     {
  12.         for (int i = a; i <=b ; i++)
  13.         {
  14.             Console.Write(i + " ");
  15.         }
  16.         Console.WriteLine();
  17.     }
  18.     public static void Triangle(int n)
  19.     {
  20.         for (int i = 1; i <=n; i++)
  21.         {
  22.             PrintLine(1, i);
  23.         }
  24.         for (int i = n-1; i >= 1; i--)
  25.         {
  26.             PrintLine(1, i);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement