Advertisement
JOHNYTHEWINNER

Problem 8.IsoscelesTriangle

Apr 8th, 2015
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2.                    
  3. public class IsoscelesTriangle
  4. {
  5.     public static void Main()
  6.     {
  7.         char unicode = '\u00A9'; //We set the correct symbol
  8.         int a =1;  // We will use it for loop so we could print how many symbols we want
  9.         int b =5;  // We will use it for loop so we could print how many symbols we want
  10.         int c=0;  // We will use it for loop so we could print base of the triangle
  11.                
  12.     {      
  13.         Console.WriteLine("      "+unicode); // This is the top of the triangle
  14.         }
  15.         do
  16.         {
  17.         string space1 = new String(' ', b); // This is empty spaces left of the triangle
  18.         string space = new String(' ', a);  // This is empty spaces inside of the triangle
  19.      Console.WriteLine(space1+unicode+space+unicode);  // This is each row
  20.         b=b-1; // Here we make one less spaces left of the triangle
  21.         a=a+2; // Here we make two more spaces inside of the triangle
  22.        
  23.            
  24.         }
  25.         while (a!=11); // "a" can't be highr because value "b" will be negative. If you want bigger triangle you should change "a" and "b" together
  26.         do
  27.         { Console.Write(unicode); //Here we print base of triangle
  28.             c=c+1;
  29.         }
  30.         while (c!=13);  // Of course we need print 2 more "a" symbols so triangle be finished (one left and one right)
  31.        }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement