1 List Reverse(List L) //带头结点的单链表 2 { 3 Node *p, *q; 4 p = L->next; 5 L->next = NULL; 6 while(p) 7 { 8 q = p->next; 9 p->next = L->next; 10 L->next = p; 11 p = q; 12 } 13 14 return L; 15 }
1 List Reverse(List L) //带头结点的单链表 2 { 3 Node *p, *q; 4 p = L->next; 5 L->next = NULL; 6 while(p) 7 { 8 q = p->next; 9 p->next = L->next; 10 L->next = p; 11 p = q; 12 } 13 14 return L; 15 }