028-86922220

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

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.tsicrk.com/article/pgdhdi.html

其他资讯

让你的专属顾问为你服务

3.0694s