kirililchev3

Draw a Filled Square

May 31st, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 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.  
  7. namespace _04.DrawFilledSquare
  8. {
  9.     public class DrawFilledSquare
  10.     {
  11.         public static void Main(string[] args)
  12.         {
  13.             int howBig = int.Parse(Console.ReadLine());
  14.             PrintSquare(howBig);
  15.         }
  16.  
  17.         static void PrintHeaderRow(int n)
  18.         {
  19.             Console.WriteLine(new string('-', 2 * n));
  20.         }
  21.  
  22.         static void PrintMiddleRow(int n)
  23.         {
  24.             Console.Write('-');
  25.             for (int i = 1; i < n; i++)
  26.             {
  27.                 Console.Write("\\/");
  28.             }
  29.             Console.WriteLine('-');
  30.         }
  31.  
  32.         static void PrintSquare(int n)
  33.         {
  34.             PrintHeaderRow(n);
  35.             for (int i = 0; i < n - 2; i++)
  36.             {
  37.                 PrintMiddleRow(n);
  38.             }
  39.  
  40.             PrintHeaderRow(n);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment