/* Èô²ÎÊý²»ºÏÀí£¬Ôò·µ»ØERROR¡£ */ {
if( NULL==L || i==0 ) return ERROR; int length=LengthLinkList(L); if( i>length )
return ERROR; LinkList p=L; while(--i>0) p=p->next; p->next=NULL; return OK; }
DS04-PE70 /**********
¡¾ÌâÄ¿¡¿ÊÔдһËã·¨£¬É¾³ý´øÍ·½áµãµ¥Á´±íÖÐËùÓÐÖµ ΪxµÄÔªËØ£¬²¢Êͷű»É¾½áµã¿Õ¼ä¡£ µ¥Á´±íÀàÐͶ¨ÒåÈçÏ£º typedef struct LNode { ElemType data; struct LNode *next; } LNode, *LinkList; **********/
Status DeleteX_L(LinkList L, ElemType x)
/* ɾ³ý´øÍ·½áµãµ¥Á´±íLÖÐËùÓÐֵΪxµÄÔªËØ£¬ */ /* ²¢Êͷű»É¾½áµã¿Õ¼ä£¬·µ»Øʵ¼Êɾ³ýµÄÔªËظöÊý¡£*/ {
if( NULL==L ) return ERROR; LinkList p; p=L;
int count=0;
if( NULL==L->next ) return count; if(NULL==p->next->next) {
if(x==p->next->data) {
count++;
p->next=NULL; }
return count; }
while(p->next->next) {
if(x==p->next->data)
{
count++;
p->next=p->next->next; } else
p=p->next; }
if(x==p->next->data) {
count++;
p->next=NULL; }
return count; }