新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

C,单链表翻转函数

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://www.wjwzjz.com/article/pgdhdi.html
在线咨询
服务热线
服务热线:028-86922220
TOP