回复 25# Super-Tomato
其实用加法比较易懂
a=a+b;
b=a-b;
a=a-b;
但是我觉得这种方法没事拿来玩玩考考人还好。
这个坏处是容易打错,而且别人难看懂,code maintanence 更麻烦。
还是用temp比较实际,temp store 的 data 还可以用作其他用途。
btw,good share for beginner.
ps:这个原本是国外的一个题目。
swap the int data store in variable a and b without using a temp/third/ variable or array.