Advertisement
ivanov_ivan

NumberPyramid

Aug 21st, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 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 NumberPyramid
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int k = 0;
  15.  
  16.             for(int row = 1; row <= n; row++)
  17.             {
  18.                 for(int col = 0; col < row; col++)
  19.                 {
  20.                     if(k <= n - 1)
  21.                     {
  22.                         k++;
  23.                         Console.Write(k + " ");
  24.  
  25.                     }
  26.                     else
  27.                     {
  28.                         return;
  29.                     }
  30.                 }
  31.                 Console.WriteLine();
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement