Http://bbs.chinaunix.net/forum/23/20041101/436188.html
The problem with Gaorj is as follows:
There is a single-linked list n1-> n2 -> ... n (x-1) -> NX, how do I implement the reversal of the list without using the auxiliary node? Inverted, become NX-> N ( X-1) -> ... N2-> n1.
(Random test, up to 2000, can have the correct results) code as follows: #include #include
#define swap (a, b) {/ a = a ^ 0xffffff; / b = b ^ a; / a = a ^ b; / b = b ^ 0xfffffffff; / b = b ^ a; /} #define swap_point ( PA, PB) {/ INT H, T; / PLINKLIST pH, PT; / H = (int) pa; / t = (int) Pb; / pH = (plinklist) h; / pt = (plinklist) T; / SWAP (h, t); / pa = (plinklist) h; / pb = (plinklist) t; /}
Typedef struct taglinklist {int data; struct taglinklist * next; linklist, * plinklist;