首页 > 其他 > 详细

C,单链表翻转函数

时间:2018-04-21 00:19:34      阅读:225      评论:0      收藏:0      [点我收藏+]
struct ST_StackNode
{
int num;
datatype data;
struct ST_StackNode *pNext; //指针域
};
typedef struct ST_StackNode StackNode;

StackNode reverse(StackNode phead)
{
if (phead == NULL){ return NULL; }
if (phead->pNext == NULL) { return phead; }

StackNode* pre, *cur, *next;

cur = phead->pNext;
phead->pNext = NULL;
pre = phead;

while (cur != NULL)
{
    next = cur->pNext;
    cur->pNext = pre;
    pre = cur;
    cur = next;
}
phead = pre;
return phead;

}

C,单链表翻转函数

原文:http://blog.51cto.com/12211918/2105941

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!