Advertisement
Guest User

IsoscelesTriangle

a guest
Sep 30th, 2014
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. class IsoscelesTriangle
  5. {
  6.     static void Main()
  7.     {
  8.         Console.OutputEncoding = Encoding.UTF8;
  9.         Console.WriteLine("Enter hight of the triangle : ");
  10.         int Height = int.Parse(Console.ReadLine());
  11.         string Symbol ="\u00A9";
  12.         //PadLeft(Int32) : Returns a new string that right-aligns the characters in this instance
  13.         //by padding them with spaces on the left, for a specified total length.
  14.         Console.Write(Symbol.PadLeft(Height));//First row.
  15.         Console.WriteLine();
  16.         for (int i = 1; i < Height - 1; i++)//The rows between the first and the last one.
  17.         {
  18.             Console.Write(Symbol.PadLeft(Height - i));
  19.             Console.Write(Symbol.PadLeft(i * 2));
  20.             Console.WriteLine();
  21.         }
  22.  
  23.         for (int i = 0; i < Height; i++)//Last row.
  24.         {
  25.             Console.Write(Symbol + " ");
  26.         }
  27.  
  28.         Console.WriteLine();
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement