anizko

02. Number Pyramid

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