Advertisement
RMarK0

Untitled

Nov 12th, 2021
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. namespace FomichevaApp
  2. {
  3.     class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             var h = int.Parse(Console.ReadLine());
  8.             h += 2;
  9.             if (h % 2 == 0)
  10.             {
  11.                 throw new NotImplementedException("Number should be odd");
  12.             }
  13.             for (var i = 0; i < h; i++)
  14.             {
  15.                 if (i == 0 || i == h-1)
  16.                 {
  17.                     Console.WriteLine("{0}", new string('+', h));
  18.                 }
  19.                 else
  20.                 {
  21.                     int spacesBefore = Math.Abs(h / 2 - i);//Количество пробелов в начале строке
  22.                     int starsCount = (h - 2 * spacesBefore);//Количество звёздочек
  23.                     Console.WriteLine("{0}{1}{2}", new string('+', spacesBefore+1), new string('o', starsCount-2), new string('+', spacesBefore+1));
  24.                 }
  25.             }
  26.             Console.Read();
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement