We changed our privacy policy. Read more.

Hot answers tagged

3

the pseudocode for Mario for height of pyramid for (calculate nr. of spaces at height) print ' ' for (calculate nr. of hashes at height) print '#' print a newline I'd defer from saying more since, well, that would kill all the fun of the problem :) Note that you've got other problems, too... your conditions aren't correct. You ...


2

Here's a hint. How many hashes in the first row? The second row? The third row? Does the number of hashes in any given row have any relationship to the height of the pyramid? Or is the number of hashes related to something else? If that's not enough of a hint, try making a pyramid with no leading spaces. The interesting thing is that most people get ...


1

What your code does is, for every time it increases i, it prints '#' 1 times more than i, followed by a /n (line break). To make right aligned, you need another for loop behind the 'loop for columns' that looks like for (int j = 0; j <= n - i; j++) and prints ' ' instead of '#'. Also, your english was fine :). Good luck!


1

Change GetInt(void) to GetInt(). In C, void is a type that of an object with no type. Calling GetInt(void) generates an error because type identifiers (Ex: int, char, double) are not passed into a function; variables are. When GetInt is declared as void GetInt(void), the void is included to signal that nothing will be passed into the function as a parameter. ...


1

In a for loop you don't state the end criteria, but think about it more like a while criteria. This means instead of spaces = row - 1; you need to use spaces <= row - 1;


1

Looks like check50 got a different file. Maybe you have forgotten to save, or you are in the wrong directory, one where you stored a solution to mario.less? check50 will always upload mario.c from current directory, it may not be renamed.


1

I don't think it's a good idea to name the loop variable spaces when that name is already taken; that's probably where it goes wrong. Also, why don't you multiply the spaces like you did with the hashes? And you need the end="" only when you don't want the newline character to be added at the end. For the last part of the line, you actually want a newline. ...


1

Your math is correct, but your understanding of the variables in the for loop isn't. On the first run, rows = 0, not 1. Look at the for loop setup code: for (rows = 0; rows < height; rows++) rows is initially set to 0 for the first pass. rows++ only increments when the loop has completed the first pass and returns to the beginning. At that point, ...


1

I don't understand your logic for setting the limits of how many #s to print. First, you're printing a blank line. This is because you're using x as a limit, but x is 0 on the first pass. It's 0 because you don't set it before the first pass and it's using 0 by default or chance. On the next pass, it's whatever is left in x from the next for loop, but ...


1

Your code prints out 4 lines of 2 #'s on each line. That's exactly what the code that you wrote should do. The good news is that you have written code that produces the right number of output lines. But the assignment is to print out a half-pyramid with the correct number of spaces and #s on each line. Now, you need to do the next step and add that code ...


1

Per the isdigit()'s man page we see These functions check whether c, which must have the value of an unsigned char or EOF, falls into a certain character class according to the current locale. So isdigit() gets a char as input. Not an int as you use it. It also checks for only one-digit numbers, for example the char '5' will ...


Only top voted, non community-wiki answers of a minimum length are eligible