Advertisement
koksibg

Numbers_Pyramid

Jul 13th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 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 Numbers_Pyramid
  8. {
  9.     class Numbers_Pyramid
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             uint n;
  14.             string str = Console.ReadLine();
  15.             bool a = UInt32.TryParse(str, out n);
  16.             int count = 0;
  17.             for (int i = 1; i <= n; i++)
  18.             {
  19.                 count++;
  20.                 if ((count <= n) && a)
  21.                 {
  22.                     Console.Write(count + " ");
  23.                     for (int j = 2; j <= i; j++)
  24.                     {
  25.                         count++;
  26.                         if ((count <= n) && a) Console.Write(count + " ");
  27.                         else
  28.                         {
  29.                             Console.WriteLine();
  30.                             return;
  31.                         }
  32.                     }
  33.                     Console.WriteLine();
  34.                 }
  35.                 else
  36.                 {
  37.                     Console.WriteLine();
  38.                     return;
  39.                 }
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement