int a, b; a ^= b; b ^= a; a ^= b; note: if a and b are pointers. this behavior probably will not work well. assume that a and b are pointing to the same varible simultaneously, if we do as the above, the result will be 0. In a conclusion, what if we meet the following cases the kinda method will not work well. first, the object a and object b have shared part of memory. second, either a or b is stored in the register or is in bitfall.
swap two values without temporary variable
最新推荐文章于 2022-10-24 08:14:08 发布