擅长:python、mysql、java
<pre><code>def flip(picture):
height = getHeight(picture)
width = getWidth(picture)
newPicture = makeEmptyPicture(width, height)
for x in range(width):
for y in range(height):
color = getColor(getPixel(picture, x, y))
setColor(getPixel(newPicture, width-1-x, y), color)
return newPicture
</code></pre>
<p>这个怎么样?我刚把那些对我来说不必要的东西去掉了。否则它应该这样工作。我在你的代码中没有发现真正的bug,只是在最后返回了<code>picture</code>,而不是<code>newPicture</code>。但这也不应该导致镜像。</p>