0
void reflect(int height, int width, RGBTRIPLE image[height][width])
{
    RGBTRIPLE temp[height][width];
    
    for (int i = 0 ; i < height ; i++)
    {
        for (int j = 0 ; j < width ; j++)
        {
            while (j < 0.5 * width)
            {
            temp[i][j] = image[i][j];
            image[i][j] = image[i][width - j - 1];
            image[i][width - j - 1] = temp[i][j];
            width-- ;
            }
        }
     }
        
        return;
    }
1
  • i tried to run it but it has errors – hosam ahmed May 5 '20 at 12:22
0

First of all, remove the while loop and just divide the width by two, i assume that's what you were trying to do with the while loop in the first place but that's what is causing the errors.

second, width-- messes with your calculation width - j - 1.

Good Luck.

2
  • Also....you could write temp as follows.... RGBTRIPLE temp = image[i][j], but yours works just fine....just thought you might want to know. – Ash May 5 '20 at 16:00
  • thanks it works fine – hosam ahmed May 7 '20 at 4:41

You must log in to answer this question.

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