# Tag Info

3

Not sure what you mean by "many" if statements, but most people will use two nested for loops to create the bricks - an inner for loop to create each row and an outer for loop to do multiple rows. Then, you only need to create one set of statements to create each brick. [EDIT - addition] There's nothing wrong with what you have done. This is a perfect ...

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

I am not sure what your problem is, but you can call break at any time, here is an example: do { // For loop 1 for (int i = 0; i < n; i++) { // For loop 2 for(int k = 0; k < n; k++) { // When condition b you can break loop 1 and loop 2 if (condition b) { i = n; ...

1

Each round counts one vote per voter, for their top preferred, non-eliminated candidate. Once that vote is counted, program moves on to the next voter. From the C99 standard section 6.8.6.3: A break statement terminates execution of the smallest enclosing switch or iteration statement. In this case it terminates the the j loop and moves on to the ...

1

Look at the value of X after you create your first row of bricks. Using your image, that's 9 bricks in the first row. The 10th brick is going to be at x=405, outside the window. How are you going to position the 10th brick as the first brick of the next row? There's something missing. (Trying to make you think instead of just giving the answer. ;-) ) ...

1

First of all, notice that inside a for loop you can use other variables as well, not only counter. E.g.: for(counter = 1; counter <= height; counter++) { int row_number = counter; int hash_quant = counter + 1; ... } Even further, you don't need to store the quantity counter + 1 in an extra variable. You could simply use it as is, in any ...

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