[ EDIT: Code has been corrected & output examples added invalidating older comments below. Next time will be better. ]
been trying this cs50 mario more problem for awhile now but i cant seem to find a solution, the right pyramid seems to print out way more than it is supposed to for some reason, my code is below, appreciate any help i can get. thanks
#include <cs50.h>
#include <stdio.h>
int h;
int k;
int j;
int main(void)
{
while (h<=0 || h>8)
{
h = get_int ("input pyramid height:");
}
for(j=0; j<h; j++)
{
for( k=0; k<=h; k++)
{
if (j+k<h)
printf(" ");
else
printf("#");
}
printf(" ");
for (int x=0; x<=j; x++)
{
for (int y=0; y<=x; y++)
printf("#");
}
printf("\n");
}
}
this is what im supposed to get for height = 4. (sorry for the lack on info earlier)
# #
## ##
### ###
#### ####
what i get is this:(
# #
## ###
### ######
#### ##########