So I was able to set up the prompt and the left aligned pyramid correctly, but really started struggling when trying to right-align it with dots in front of the hashes. For whatever reason, its printing extra dots in between the hashes on each line. The hashes and rows are correct. I thought the third nested loop should have space = row - hash
to get the correct amount of dots before the hashes, but it still prints the wrong amount of dots and places them between hashes. Has anyone else experienced this problem? My code for that section of the problem is below:
for (int row = 0; row < height; row++)
{
for (int hash = height - row; hash <= height; hash++)
{
for (int space = height - row; space >= 0; space--)
{
printf(".");
}
printf("#");
}
printf("\n");
}
The output looks something like this for a height = 5:
......#
.....#.....#
....#....#....#
...#...#...#...#
..#..#..#..#..#