Advertisement
saimun1

Pyramid of numbers

Jul 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace test
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int n = int.Parse(Console.ReadLine());
  15.             int num = 1;
  16.             for (int row = 0; row < n; row++)
  17.             {
  18.                 for (int col = 0; col <= row; col++)
  19.                 {
  20.                     if(col>=1)
  21.                         Console.Write(" ");
  22.                     Console.Write(num);
  23.                     num++;
  24.                     if (num > n)
  25.                         break;
  26.                 }
  27.                 Console.WriteLine();
  28.                 if (num > n)
  29.                     break;
  30.             }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.             Console.ReadLine();
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement