Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Collections.Generic;
- using System.Linq;
- public class IsoscelesTriangleThree
- {
- public static void Main()
- {
- Console.OutputEncoding = Encoding.Unicode;
- char unicode = '\u00A9';
- int b = 6;
- int c = 0;
- // The halfTriangle list will be storing the first half of our isosceles triangle
- List<string> halfTriangle = new List<string>();
- // will be storing the half of the hypotenuse
- StringBuilder line = new StringBuilder();
- // calculates all strings necessary for one cathetus of the triangle
- // stores them in the halfTriangle list
- do
- {
- string space1 = new String(' ', b);
- string print = space1 + unicode;
- halfTriangle.Add(print);
- b = b - 1;
- } while (b != 0);
- // builds a string for a half-hypotenuse
- do
- {
- line.Append(unicode);
- c = c + 1;
- }
- while (c != 7);
- // storing this half-hypotenuse into the halfTriangle list
- halfTriangle.Add(line.ToString());
- // printing the left half of the triangle
- foreach (string str in halfTriangle)
- {
- Console.WriteLine(str);
- }
- // printing the right half of the triangle as a mirror image of the left one
- for (int i = 0; i < halfTriangle.Count; i++)
- {
- Console.SetCursorPosition(6, i);
- var temp = halfTriangle[i].Reverse();
- Console.WriteLine("{0, 7}", string.Join("", temp));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement