Advertisement
Guest User

Isosceles Triangle - Mirror Upper and Lower Halves

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