posts - 63, comments - 37, trackbacks - 0, articles - 0
  IT博客 :: 首页 :: 新随笔 :: 联系 ::  :: 管理

链表的删除

Posted on 2006-06-22 23:32 Enjoy Life 阅读(402) 评论(0)  编辑 收藏 引用 所属分类: 程序员面试功略

//为了能够将函数处理的链表顺利的传出该函数,head必须用指针的指针
int DeleteElem(LNode **head, LNode *DElem){
         LNode *elem;
         elem=*head;
         if(DElem == *head){
               *head = elem->next;
                free(DElem);
                return 1;   
         }
         while(elem){
                  if(elem->next == DElem){
                           elem->next = DElem->next;
                           free(DElem)
                           return 1;
                    }
                     elem = elm->next;
         
         }
         return 0;
}

只有注册用户登录后才能发表评论。