EmoRz

Number Pyramid

Aug 22nd, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         var n = int.Parse(Console.ReadLine());
  8.         var num = 1;
  9.        
  10.         for(int row = 1; row <= n; row++)
  11.         {
  12.             for(int col = 1; col <= row; col++)
  13.             {
  14.                 if(col>1)
  15.                 {
  16.                     Console.Write(" ");
  17.                    
  18.                 }
  19.                 Console.Write(num);
  20.                 num++;
  21.                 if(num>n)
  22.                 {
  23.                     break;
  24.                 }
  25.             }
  26.             Console.WriteLine();
  27.             if(num>n)
  28.             {
  29.                 break;
  30.             }
  31.         }      
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment