Advertisement
Guest User

Isosceles Triangle - Mirror Upper and Lower Halves

a guest
Apr 10th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. class IsoscelesTriangleSix
  6. {
  7.     static void Main()
  8.     {
  9.         Console.OutputEncoding = Encoding.Unicode;
  10.  
  11.         string unicode = '\u00A9'.ToString();
  12.         int b = 0;
  13.  
  14.         // The halfTriangle list will be storing the upper half of our isosceles triangle
  15.         List<string> halfTriangle = new List<string>();
  16.  
  17.         halfTriangle.Add(unicode);
  18.  
  19.         // calculates all strings necessary for one cathetus of the triangle
  20.         // stores them in the halfTriangle list
  21.         do
  22.         {
  23.             string space = new String(' ', b);
  24.             string print = unicode + space + unicode;
  25.             halfTriangle.Add(print);
  26.             b = b + 1;
  27.         } while (b != 6);
  28.  
  29.         // printing the upper half of the triangle
  30.         for (int i = 0; i < halfTriangle.Count; i++)
  31.         {
  32.             Console.WriteLine(halfTriangle[i]);
  33.         }
  34.  
  35.         // printing the lower half of the triangle
  36.         for (int i = halfTriangle.Count - 2; i >= 0; i--)
  37.         {
  38.             Console.WriteLine(halfTriangle[i]);
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement