把a,b,c,d按从小到大的顺序排列**
第一种 :
(a > b) { t = a; a = b; b = t; }; (a > c) { t = a; a = c; c = t; }; (a > d) { t = a; a = d; d = t;} (b > c) { t = b; b = c; c = t; }; (b > d) { t = b; b = d; d = t; } (c > d) { t = c; c = d; d = t; };
第二种 :
a = a + b; b = a - b; a = a - b; a = a + c; c = a - c; a = a - c; a = a + d; d = a - d; a = a - d; b = b + c; c = b - c; b = b - c; b = b + d; d = b - d; b = b - d; c = c + d; d = c - d; d = c - d;
第三种:
{a = a^ b; b = a ^ b; a = a ^ b;} {a = a ^ c; c = a ^ c; a = a ^ c;} {a = a ^ d; d = a ^ d; a = a^ d;} {b = b ^ c; c = b ^ c; b = b ^ c;} {b = b ^ d; d = b ^ d; b = b - d;} { c = c ^ d; d = c ^ d; d = c ^ d;}