Advertisement
leogvozdkov

пирамидаМетод

Aug 17th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 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. using System.Threading;
  7.  
  8. namespace ConsoleApp5
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.  
  15.             DrawPyramide(10);
  16.             Thread.Sleep(5000);
  17.             Console.Clear();
  18.             DrawPyramide(5);
  19.             Thread.Sleep(5000);
  20.             Console.Clear();
  21.             DrawPyramide(7);
  22.             Thread.Sleep(5000);
  23.             Console.Clear();
  24.             DrawPyramide(11);
  25.  
  26.         }
  27.  
  28.         static void DrawPyramide(int pyramideSize)
  29.         {
  30.             if (pyramideSize >= 10)
  31.             {
  32.                 pyramideSize = 1;
  33.             }
  34.             for (int x = 0; x < (pyramideSize * 2); x++)
  35.             {
  36.                 for (int y = 0; y < (pyramideSize * 2); y++)
  37.                 {
  38.                     Console.SetCursorPosition(x, y);
  39.                     int min = x < y ? x : y;
  40.                     int max = x > y ? x : y;
  41.                     if (x + y < (pyramideSize * 2))
  42.                     {
  43.                         Console.Write(min + 1);
  44.                     }
  45.                     else
  46.                     {
  47.                         Console.Write((pyramideSize * 2) - max);
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement