设计一个递归算法删除不带头节点单链表L中所有值为x的节点

#include "stdafx.h"
#include 
#include 
#include
typedef int type;
typedef struct lnode //定义链表结点的数据结构 
{
    int data;
    struct lnode *next;
}Lnode;
typedef Lnode node;
typedef struct dnode//定义双链表结点的数据结构 
{
    int data;
    struct dnode *lnext;
    struct dnode *rnext;
}Dnode;
void recursiondel1(node *h, type x)
{
    node *p;
    if (h == NULL)
        return;
    if (h->data == x)
    {
        p = h;
        h = h->next;
        free(p);
        recursiondel1(h, x);
    }
    else
        recursiondel1(h->next, x);

}

你可能感兴趣的:(数据结构与算法)