c# - Creating an isosceles triangle in C3 -
the code below makes right angle triangle, how make isosceles triangle?
int height = 4; string star = ""; (int = 0; int < height; i++) { star += "*"; console.writeline(star); } console.readline();
this displays right angle triangle. attempted make pyramid.
here have cleaner code:
int numberoflayer = 4; int empty; int number; (int = 1; <= numberoflayer; i++) { (empty = 1; empty <= (numberoflayer - i); empty++) console.write(" "); (number = 1; number <= i; number++) console.write('*'); (number = (i - 1); number >= 1; number--) console.write('*'); console.writeline(); }
Comments
Post a Comment