Advertisement
gospod1978

Methods/Print Triangle

Oct 11th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Printing_Triangle
  5. {
  6.     public class Printing_Triangle
  7.     {
  8.         public static void Main()
  9.         {
  10.  
  11.             int n = int.Parse(Console.ReadLine());
  12.  
  13.             PrintFigure(n);
  14.  
  15.         }
  16.         static void PrintCol(int row)
  17.         {
  18.             for (int col = 1; col <= row; col++)
  19.             {
  20.                 Console.Write(col + " ");
  21.             }
  22.             Console.WriteLine();
  23.  
  24.         }
  25.         static void PrintFigure(int n)
  26.         {
  27.             for (int row = 1; row <= n; row++)
  28.             {
  29.                 PrintCol(row);
  30.             }
  31.  
  32.             for (int row = n - 1; row >= 1; row--)
  33.             {
  34.  
  35.                 PrintCol(row);
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement