0

I watched the walkthroughs and shorts for problem set 1 Mario, and I was able to properly get the pyramid's height. However, I am struggling to figure out how to loop through the pyramid's height. How do I use a for-loop to loop through the height while still keeping track of the spaces?

Thanks in advance.

1

For starters take a look at the pyramid and once again read the condition. For example, you can draw the line by typing each character. Number of characters per line is determined by the height of the pyramid and one of the conditions of the task. So, you need a loop, and several conditions in it. I did so.

P.S. Sorry for my English. I used Google Translate.

9
  • Would I print the hashes and spaces in a single loop? What type of conditions would I use? – SuperNovaCoder Aug 11 '16 at 13:46
  • You have two variables - lines and signs. Thus, you can make the count 2. The first and main - will control loop. The second is to check the conditions, "What char is now printed? Space or hash" - the characters count decreased. And if you got to 0, then he moved on to a new line and restored the counter (this reduces the row count). – Teo Aug 11 '16 at 13:59
  • It is not bad. But, it seems to me, that better use of "do{}while()", because you first need to check user input. – Teo Aug 11 '16 at 14:50
  • Your idea is well. You will need to think about conditions, where you be typing spece or hash, that will be decresing counter – Teo Aug 11 '16 at 15:03
  • I have a do/while loop for user input. Is there anyway to multiply a printf statement so that way it will decrease by one each time we go to another row? – SuperNovaCoder Aug 11 '16 at 15:29
1

In your code you include the value "24" and not include the value "0" as a choice for the users input. This will make you fail the check50 test and you must change it. In addition, you have to consider a code block similar to the one you wrote for hashes, for the space characters. Once you find the correct loop for spaces you must find a new loop with reversed counting for the hashes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .