C,单链表翻转函数-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

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://kswsj.cn/article/pgdhdi.html

其他资讯