Advertisement
BorisSimeonov

Isosceles Triangle

Nov 4th, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2.  
  3.     class Program
  4.     {
  5.         static void Main()
  6.         {
  7.             Console.OutputEncoding = System.Text.Encoding.Unicode;
  8.             char ch = '\u00A9';
  9.             int height = 4;
  10.             int buffer = height - 1;
  11.             int colCount = (height*2)-1;
  12.             for (int cntRow = 0; cntRow < height; cntRow++ )
  13.             {
  14.                 for (int cntCol = 1; cntCol <= colCount; cntCol++ )
  15.                 {
  16.                     if (cntRow < (height - 1))
  17.                     {
  18.                         if (cntCol == (colCount - buffer) || cntCol == (buffer + 1))
  19.                         {
  20.                             Console.Write(ch);
  21.                         }
  22.                         else
  23.                         {
  24.                             Console.Write(" ");
  25.                         }
  26.                     }
  27.                     else
  28.                     {
  29.                         Console.Write(cntCol % 2 == 0 ? " " : "{0}", ch);
  30.                     }
  31.                 }
  32.                 buffer--;
  33.                 Console.WriteLine();
  34.             }
  35.         }
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement