两个值要交换 int n=3,m=8; //1.通过第三方变量交换 int temp; temp=n; n=m; m=temp; 2.不通过第三方交换(如果n和m的值非常大,容易超出int的范围) n=n+m; m=n-m; n=n-m; 或 n=n^m; m=n^m; n=n^m;