Making pyramid using c# -
my question how make pyramid using * , 'space' in c#? output this.
* * * * * * * * * * * * * * * we need use "for loop" program. know how make one.
* ** *** **** ***** i made program this:
static void main(string[]args) { int i=o; int j=o; for(i=5;1>=1;i--) for(j=1;j<=5;j++) { console.write("*"); } console.writeline(" "); } i'm confused when comes pyramid because includes spaces. help!
think how you'd print pyramid manually.
suppose 5 levels deep.
1st line: 4 spaces, 1 star, 2nd line: 3 spaces, star, space, star 3rd line: 2 spaces, star space star space star etc.
doesn't matter whether print spaces after last star or not - won't make difference how looks.
what see?
if have total of x levels
line 1: (x-1) spaces, (star space) line 2: (x-2) spaces, (star space) twice line 3: (x-3) spaces, (star space) 3 times line 4: (x-4) spaces, (star space) 4 times that's pattern. i'll leave coding you.
Comments
Post a Comment