改了好几次都一直显示段错误,想麻烦各位帮我看看是哪里出了问题
Position Find( List L, ElementType X ){
Position ptrl = L;
while(ptrl != NULL && ptrl->Data != X){
ptrl = ptrl->Next;
}
if( ptrl->Data == X){
return ptrl;
}
else{
return ERROR;
}
}
List Insert( List L, ElementType X, Position P ){
Position ptrl = L;
List s = (List)malloc(sizeof(struct LNode));
s->Data = X;
if( P == L){
s->Next = P;
L = s;
return L;
}
else if( P == NULL){
printf("Wrong Position for Insertion");
return ERROR;
}
else{
while( ptrl != NULL && ptrl->Next!=P){
ptrl = ptrl->Next;
}
s->Next = ptrl->Next;
ptrl->Next = s;
return L;
}
}
List Delete( List L, Position P ){
Position ptrl = L;
if( P == L){
if( L != NULL){
L = ptrl->Next;
}
else{
return ERROR;
}
free( P);
return L;
}
else if( P == NULL){
return ERROR;
}
else{
while( ptrl != NULL && ptrl->Next != P){
ptrl = ptrl->Next;
}
if( ptrl->Next == P){
ptrl->Next = P->Next;
free(P);
return L;
}
}
}