Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - 49. let x and y be int variables, then the following statement: x+= y; y = x-y; y = x-y; x-= y; The function of is
49. let x and y be int variables, then the following statement: x+= y; y = x-y; y = x-y; x-= y; The function of is
X+=y is equivalent to x=x+y, and the sum of x and y is given to X.

Y=x-y=(x+y)-y=x, and assign the original value of x to y.

X-=y is equivalent to x=x-y=x+y-x=y, and the initial value of y is assigned to X.

The function of the statement is to exchange the values of x and y.

Choose D.