Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class IsoscelesTriangle
- {
- static void Main()
- {
- Console.OutputEncoding = System.Text.Encoding.UTF8;
- byte triangleHeight;
- char copyrightSymbol = '\x00a9';
- char spaceSymbol = ' ';
- byte innerSpacesCount = 1;
- Console.Write("Height of Triangle (0-254): ");
- bool bCorrectHeight = byte.TryParse(Console.ReadLine(), out triangleHeight);
- if (bCorrectHeight)
- {
- for (int row = 1; row <= triangleHeight; row++)
- {
- int leftSpacesCount = triangleHeight - row;
- Console.Write(new string(spaceSymbol, leftSpacesCount));
- Console.Write(new string(copyrightSymbol, 1));
- if (row > 2)
- {
- innerSpacesCount += 2;
- }
- if (row != 1 && row != triangleHeight)
- {
- Console.Write(new string(spaceSymbol, innerSpacesCount));
- Console.Write(new string(copyrightSymbol, 1));
- }
- else if (row == triangleHeight)
- {
- for (int i = triangleHeight; i > 1; i--)
- {
- Console.Write(new string(spaceSymbol, 1));
- Console.Write(new string(copyrightSymbol, 1));
- }
- }
- Console.WriteLine();
- }
- }
- else
- {
- Console.WriteLine("Please enter correct height - a number between 0 and 255.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement