1

So i came up with this solution to the reflect function. It seems to properly reflect all the images but i'm getting all errors on check50. Trying to figure out what went wrong. We are encouraged to use the swap function but i thought this solution was easier.

// Reflect image horizontally void reflect(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE buffer[height][width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { buffer[i][j] = image[i][j]; } for (int j = 0; j < width; j++) { image[i][j] = buffer[i][width - j]; } } return; } 

1 Answer 1

1

i figured it out, i needed to do width - j -1 for the second embedded for loop

1
  • Here's an exercise for you. Can you do it with one less loop and without the buffer? Hint: if it produces the original image, you're really close. You just didn't know when to stop processing! ;-) Commented Dec 4, 2022 at 3:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.