Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Week3
  4. {
  5.   class Program
  6.   {
  7.     static void Main(string[] args)
  8.     {
  9.       int n = int.Parse(Console.ReadLine());
  10.  
  11.       for (int row = 1; row <= n; row++)
  12.       {
  13.         char side = '/', middle = ' ';
  14.         // if we are on first or last row - we put '*' on both sides(left and right) instead of '/'
  15.         if (row == 1 || row == n)
  16.         {
  17.           side = '*';
  18.         }
  19.         //if we are on "middle" row we put '|' instead of ' '
  20.         if (row == (n + 1) / 2)
  21.         {
  22.           middle = '|';
  23.         }
  24.         //set template for each row
  25.         Console.WriteLine("*{0}*{1}*{0}*", new string(side, 2*n -2), new string(middle, n));
  26.       }
  27.     }
  28.   }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement