Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def exchangeRowAndColumn(A,x,y):
  2. # @param A: Picture;
  3. # @param x: int; column number
  4. # @param y: int; row number
  5.   if getWidth(A) != getHeight(A) or x >= getWidth(A) or y >= getHeight(A) or x<0 or y<0:
  6.     print "Error in parameter settings"
  7.     return
  8.  
  9.   for i in range(0,getWidth(A)):
  10.       px_1 = getPixel(A,x,i)
  11.       px_2 = getPixel(A,i,y)
  12.       color_1 = getColor(px_1)
  13.       color_2 = getColor(px_2)
  14.       setColor(px_1,color_2)
  15.       setColor(px_2,color_1)
  16.   repaint(A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement