Advertisement
Filkolev

Number Pyramid

Feb 17th, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.  
  9.         int lineLength = 1;
  10.         int currentLineLength = 0;
  11.  
  12.         for (int i = 1; i <= n; i++)
  13.         {
  14.             Console.Write(i + " ");
  15.             currentLineLength++;
  16.             if (currentLineLength == lineLength)
  17.             {
  18.                 Console.WriteLine();
  19.                 lineLength++;
  20.                 currentLineLength = 0;
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement