VelizarAvramov

04. Draw a Filled Square

Nov 17th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04._Draw_a_Filled_Square
  4. {
  5.     class DrawFilledSquare
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             PrintLines(n);
  12.             PrintMiddlePart(n);
  13.             PrintLines(n);            
  14.         }
  15.  
  16.         private static void PrintMiddlePart(int n)
  17.         {
  18.             for (int i = 0; i < n - 2; i++)
  19.             {
  20.                 Console.Write("-");
  21.                 for (int j = 1; j < n; j++)
  22.                 {
  23.                     Console.Write("\\/");
  24.                 }
  25.                 Console.WriteLine("-");
  26.             }
  27.         }
  28.  
  29.         private static void PrintLines(int n)
  30.         {
  31.             Console.WriteLine(new string('-', 2 * n));
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment