更新时间:2023-11-10 09:23:58
你没有提供足够的信息来了解更多细节,所以我猜这是一个单独喜欢的列表.如果是这样,您需要遍历您的列表一次.
You don't provide enough informations to have more details, so I guessed it is a singly liked list. If so, you need to run through your list once.
void reverse(struct node **p) {
struct node *buff = NULL;
struct node *head = *p;
while (head != NULL) {
struct node *temp = head->next;
head->next = buff;
buff = head;
head = temp;
}
*p = buff;
}