typedef struct LNode
{
int data;
struct LNode *next;
}LNode, *Linklist;
Linklist reverselink(Linklist *list)
{
Linklist newlist;
LNode *tmp;
if (list == NULL || newlist = (LNode *)malloc(sizeof(LNode)))
{
return NULL;
}
newlist->data = list->data;
newlist-next = NULL;
while (list->next != NULL)
{
tmp = newlist->next;
newlist->next = list->next;
list->next = list->next->next;
newlist->next->next = tmp;
}
free(list);
return newlist;
}
阅读(519) | 评论(0) | 转发(0) |