Advertisement
Qrist

Triangle With Different Size (Nakov)

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