Advertisement
rank0001

Untitled

Nov 19th, 2021
1,136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using static System.Console;
  6.  
  7.  
  8. namespace Problem_Solving
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int n = int.Parse(Console.ReadLine());
  15.             int columnAbove = n - 2;
  16.             int spaceAbove = 1;
  17.             for (int i = 0; i < n; i++)
  18.             {
  19.                 int col = i > (n / 2) ? columnAbove : 2 * i + 1;
  20.                 int space = i > (n / 2) ? spaceAbove : (n / 2) - i;
  21.                 for (int k = 0; k < space; k++)
  22.                 {
  23.                     Write(" ");
  24.                 }
  25.                 for (int j = 1; j <= col; j++)
  26.                 {
  27.                     Write("*");
  28.                 }
  29.                 WriteLine();
  30.                 if (i > (n / 2))
  31.                 {
  32.                     columnAbove -= 2;
  33.                     spaceAbove++;
  34.                 }
  35.             }
  36.         }
  37.  
  38.     }
  39.  
  40. }
  41.  
  42.  
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement