Switching for two variables without temporary variables (from 9CBS Forum Post)

xiaoxiao2021-03-06  48

Although I learned over the operation operator, I looked at it every time, I didn't expect to play on this issue.

Value type exchange:

1. User operator:

INT A = 5; int b = 6;

A = a ^ b; b = a ^ b; a = a ^ b;

2. Utilize the addition and subtraction method:

A = a b; b = a - b; a = a - b;

Character type exchange (using string functions):

A = a b; b = a.substring (0, a.length-b.length); a = a.sbstring (B.Length);

The foundation of the 俺 has to strengthen

转载请注明原文地址:https://www.9cbs.com/read-40706.html

New Post(0)