Advertisement
Guest User

Problem09.IsoscelesTriangle

a guest
Mar 14th, 2014
185
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.        
  13.     //PadLeft(Int32) : Returns a new string that right-aligns the characters in this instance
  14.         //by padding them with spaces on the left, for a specified total length.
  15.         Console.Write(Symbol.PadLeft(Height));//First row.
  16.         Console.WriteLine();
  17.        
  18.     for (int i = 1; i < Height - 1; i++)//The rows between the first and the last one.
  19.         {
  20.             Console.Write(Symbol.PadLeft(Height - i));
  21.             Console.Write(Symbol.PadLeft(i * 2));
  22.             Console.WriteLine();
  23.         }
  24.  
  25.         for (int i = 0; i < Height; i++)//Last row.
  26.         {
  27.             Console.Write(Symbol + " ");
  28.         }
  29.  
  30.         Console.WriteLine();
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement