基於c 的單鏈表,雙向鍊錶操作以及環

2021-07-05 15:24:47 字數 1597 閱讀 4803

1:單向鍊錶:生成,頭插入,尾插入,某個元素後面插入,刪除某元素

#includeusing namespace std;

struct node;

node* create()

else

scanf("%d",&a);

}return h;

}void addafter(node* head,int data,int afdata)

else

}}node* deletedata(node* head,int data)

else

}while(p->next!=null)

else

break;

}else

}return head;

}void addtail(node* head,int data)

node *tmp=new node();

tmp->data=data;

tmp->next=null;

p->next=tmp;

}node* addhead(node* head,int data)

void show(node* head)

printf("\n");

}int main()

:2:雙向鍊錶操作::生成,正序/逆序遍歷,頭插入,尾插入,某個元素後面插入,刪除某元素

#includeusing namespace std;

struct node;

node* create()

else

scanf("%d",&a);

}return h;

}void addafter(node* head,int data,int afdata)

else

}}node* deletedata(node* head,int data)

else

}while(p->next!=null)

else

break;

}else

}return head;

}void addtail(node* head,int data)

node *tmp=new node();

tmp->data=data;

tmp->next=null;

tmp->pre=p;

p->next=tmp;

}node* addhead(node* head,int data)

void show(node* head)

printf("\n");

}void upshow(node* head)

while(p)

printf("\n");

}int main()

return null;

}

4:判斷鍊錶環人長度 

int  getringlen(node *meeting)  

return 0;

}

單鏈表以及雙向鍊錶的操作

include include define max 30 typedef struct s 單向鍊錶的儲存結構 s,linklist typedef struct dulist 雙向鍊錶的儲存結構 dulnode,dulinklist int initlist s s 建立空的單鏈表 void s...

鍊錶的基本操作 單鏈表 雙向鍊錶 迴圈鍊錶

本週第一次講座,學長給我們簡單的概述了資料結構和演算法,然後對鍊錶的一些操作進行了講解,下來之後,我把原來書上的一些 鍊錶的基本操作與鍊錶的逆置,排序等操作結合起來,整理出來 鍊錶是由結點構成的,關鍵是定義結點 c語言程式設計上兩大特例 鍊錶節點的定義 遞迴函式的定義。這兩個違反了先定義再使用。3....

單鏈表的增刪查改,以及雙向鍊錶的有關操作

最近在回顧線性儲存結構 鏈式儲存有關的操作,到現在基本上覆習完畢,整理相關 如下 include include include struct nodenode typedef struct node linklist linklist createmptylist 建立空表 p next null...