LinkReverse

####Link Reverse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Node * reverse_link(Node *cur){
if(cur == NULL){
return cur;
}

if(cur->next == NULL){
return cur;
}

Node *tmp = reverse_link(cur->next);
cur->next->next = cur;
cur->next = NULL;
return tmp;
}

Node * reverse_link_loop(Node *cur){
Node *pre = NULL;
Node *next= NULL;

while(cur){
next = cur->next;
cur->next = pre;
pre = cur;
cur = next;
}
return pre;
}