Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace MMTask
  6. {
  7.     public class Program
  8.     {
  9.         public static void Main()
  10.         {
  11.             int input = int.Parse(Console.ReadLine());
  12.             int halvedRows = (input / 2) + 1;
  13.             List<string> figure = new List<string>();
  14.             StringBuilder drawer = new StringBuilder();
  15.  
  16.             DrawUpperPart(input, halvedRows, drawer, figure);
  17.             DrawBottomPart(input, halvedRows, drawer, figure);
  18.  
  19.             foreach (var row in figure)
  20.             {
  21.                 Console.WriteLine($"{row}{row}");
  22.             }
  23.         }
  24.  
  25.         public static void DrawUpperPart(int input, int rows, StringBuilder drawer, List<string> figure)
  26.         {
  27.             for (int i = 0; i < rows; i++)
  28.             {
  29.                 drawer.Clear();
  30.                 drawer.Append(new string('-', input - i));
  31.                 drawer.Append(new string('*', input + (2 * i)));
  32.                 drawer.Append(new string('-', input - (2 * i)));
  33.                 drawer.Append(new string('*', input + (2 * i)));
  34.                 drawer.Append(new string('-', input - i));
  35.  
  36.                 figure.Add(drawer.ToString());
  37.             }
  38.         }
  39.  
  40.         public static void DrawBottomPart(int input, int rows, StringBuilder drawer, List<string> figure)
  41.         {
  42.             for (int i = 0; i < rows; i++)
  43.             {
  44.                 drawer.Clear();
  45.                 drawer.Append(new string('-', input - rows - i));
  46.                 drawer.Append(new string('*', input));
  47.                 drawer.Append(new string('-', i * 2 + 1));
  48.                 drawer.Append(new string('*', (input * 2) - i * 2 - 1));
  49.                 drawer.Append(new string('-', i * 2 + 1));
  50.                 drawer.Append(new string('*', input));
  51.                 drawer.Append(new string('-', input - rows - i));
  52.                 figure.Add(drawer.ToString());
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement