c语言程序老出错:( 从单链表中删除指定的元素)

来源:百度知道 编辑:UC知道 时间:2024/05/31 14:40:12
#define TURE 1
#define FLASE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
#define NULL 0
typedef int Elemtype;
typedef struct LNode
{
Elemtype data;
struct LNode *next;
}LNode;

LNode *L;
LNode creat();
LNode *Delete_List(LNode *L,ElemType e);
Print_List(LNode L);

#include"ADT.h"
#include"2_1.h"
void main()
{ int n;
printf("\n\t1.jin ru cheng xu\n\t2.end\n choose: ");
scanf("%d",&n);
switch(n){
case 1 : caozuo();
case 2 : exit(0);
}

}
#include"ADT.h"
#include"2_2.h"
#include"2_3.h"
#include"2_4.h"
void caozuo()
{
char k;
ElemType a;
do{
L=creat();
out_L(L);

贴一个能行的给你参考一下
template < class ELEM >
struct ListNode {
ELEM data; //存放数据
ListNode * next; //存放下一个节点的地址
};

template < class ELEM >
class CSinglyList {
public:
CSinglyList();
~CSinglyList();
ListNode< ELEM > * findIndex( const int & ) const;
CSinglyList< ELEM > & insertAfter( const ELEM &, const int & );
CSinglyList< ELEM > & removeAfter( const int & );
bool isEmpty() const;
int getLength() const;
void print() const;
private:
ListNode< ELEM > * first;
ListNode< ELEM > * last;
};

//构造,分配一个头节点
template < class ELEM >
CSinglyList< ELEM >::CSinglyList()
{
first = new ListNode< ELEM >; //分配头节点地址
assert( first != NULL ); //测试是否分配到地址
first->next = NULL; //下一个节点地址初始化
last = first; //尾指针初始化
}

//析构,释放空间<