typedef struct node { int data; struct node *link; }NODE; void reverse(NODE head) { NODE temp = null; NODE p = head->link; head->link = null;// 头结点变为尾结点 while(p!=null) { temp = p->link; p->link = head;// 当前结点指针倒置 head = p; p = temp; } }
typedef struct node { int data; struct node *link; }NODE; void reverse(NODE head) { NODE temp = null; NODE p = head->link; head->link = null;// 头结点变为尾结点 while(p!=null) { temp = p->link; p->link = head;// 当前结点指针倒置 head = p; p = temp; } }