设计一个算法,在一个单链表中值为y的结点前插入一个值为x的结点。

来源:百度知道 编辑:UC知道 时间:2024/06/28 00:29:07
即使值为x的新结点成为y结点的前驱结点

以前写过!

#include<stdio.h>
#include <stdlib.h>
#include <math.h>

/************************************************************************/
/* 常量定义 */
/************************************************************************/
#define ElemType int
#define Status int
#define TRUE 1
#define OK 1
#define FALSE 0
#define ERROR -1

/************************************************************************/
/* 线性表的单链表存储结构*/
/************************************************************************/
typedef struct LNode
{
ElemType data;
struct LNode *next;
}LNode, *LinkList;

/************************************************************************/
/* 操作结果:构造一个空的线性表L */
/************************************************************************/
void InitList(LinkList *L)
{
*L = (LinkList)malloc(sizeof(st