單鏈表的基本操作

2021-06-13 04:29:27 字數 865 閱讀 8767

由於做的畢業設計用到了鍊錶,所以將就就鍊錶的一些基本的操作自己寫了下來,以後看看吧,省得每次用到鍊錶都要自己寫了,寫一次就行了

(很多不合理的地方,以後留著改吧)

#include

#include

#include

typedef struct node

link;

link *cre_link()

link *insert_link(link *head,link *new_node)

while(temp->next)

temp->next = new_node;

new_node->next = null;

return head;

} void display_link(link *head)

while(temp)

}link* delete_node(link *head,char *ptr)

p = p->next;

q->next = p->next;

free(p);

return head;

}void find_node(link *head,char *ptr)

p = head->next;

while(p)

p = p->next;

}printf("no this element\n");

}link *reverse_link(link *head)

s->next=p; 

head->next->next=null;//收尾 

head->next=s;//賦頭 

return head;

}主函式就不用了,方便以後和我一樣的菜鳥學習

單鏈表基本操作

include include include include includeusing namespace std typedef struct node node,plinklist plinklist createfromhead node pstnode node malloc sizeof...

單鏈表基本操作

單鏈表的初始化,建立,插入,查詢,刪除。author wang yong date 2010.8.19 include include typedef int elemtype 定義結點型別 typedef struct node node,linkedlist 單鏈表的初始化 linkedlist...

單鏈表基本操作

include using namespace std define namelenth 20 define ok 0 define error 1 typedef struct flagnode node 生成結點 inline node newnode 銷毀化煉表 void destroylin...