#include
#include
void look_shuju(struct node* phead); //檢視資料
struct node* finddate(struct node* phead, int idate); //查詢資料
struct node* findindex(struct node* phead, int iindex); //根據下標查詢資料
void showdate(struct node* pnode); //輸出查詢結果
int count(struct node* phead, int idate); //統計指定資料的數量
void getnode(struct node* phead, struct node* arr[4], int idate); //根據資料得到對應的節點
void change_shuju(struct node* phead, int i, int changei); //修改資料 //位址;要修改的資料;修改為
int main(void)
,b = ,
c = ,
d = ;
a.pnext = &b;
b.pnext = &c;
c.pnext = &d;
//printf("%d\n", a.shuju);
//printf("%d\n", a.pnext ->shuju );
//printf("%d\n", a.pnext ->pnext ->shuju );
//printf("%d\n", a.pnext->pnext ->pnext ->shuju);
//struct node* phead = &a;
//printf("%d\n", phead->shuju);
//phead = phead->pnext;
//printf("%d\n", phead->shuju);
//phead = phead->pnext;
//printf("%d\n", phead->shuju);
//phead = phead->pnext;
//printf("%d\n", phead->shuju);
//look_shuju(&a); //檢視資料
//struct node* pfind=finddate(&a, 3); //查詢資料
//if (pfind == null)
// printf("未找到節點\n");
//else
// printf("已找到節點:%d\n", pfind->shuju );
//struct node* pfind=findindex(&a, 2); //按下標查詢資料
//if (pfind == null)
// printf("未找到該下標對應的節點\n");
//else
// printf("已找到該下標對應的節點:%d\n", pfind->shuju );
//printf("出現的次數為:%d\n",count(&a, 2) ); //統計指定資料的數量
//showdate(findindex(&a, 2)); //顯示輸出函式
//struct node* arr[4] = ;
//getnode(&a, arr, 2);
//for (int i = 0; i < 4 && arr[i] != null; i++)
//////頭新增
//struct node a = ;
//look_shuju(&a);
////尾新增
//struct node b = ;
= &b;
//look_shuju(&a);
////中間新增
//struct node c = ;
= &c;
//look_shuju(&a);
////刪除頭
= null;
//look_shuju(&b);
////刪除尾
= null;
//look_shuju(&a);
////刪除中間
= null;
= &d;
//look_shuju(&a);
////修改資料
//look_shuju(&a);
//printf("修改後:\n");
//change_shuju(&a, 2, 222);
//look_shuju(&a);
system("pause>0");
return 0;
}void look_shuju(struct node* phead)
}struct node* finddate(struct node* phead, int idate)
return null; //未找到資料
struct node* findindex(struct node* phead, int iindex)
inum++;
phead = phead->pnext;
}return null;
}void showdate(struct node* pnode)
int count(struct node* phead, int idate)
return icount;
}void getnode(struct node* phead, struct node* arr[4], int idate)
phead = phead->pnext;}}
void change_shuju(struct node* phead, int i, int changei)
phead = phead->pnext;}}
鍊錶的相關操作
連線兩個迴圈單鏈表 p a next 儲存a表的頭結點位置 a next b next next b的開始結點鏈結到a表尾 free b next b next p return b 注 a,b為已構建好的迴圈鍊錶,具有尾指標 鍊錶中的環附 include include struct node s...
鍊錶,反向鍊錶的相關操作
假設鍊錶節點的資料結構為 struct node 建立單鏈表的程式為 struct node create unsigned int n node p head for unsigned int i 1 i n i return head 問題1 鍊錶逆置 思想為 head指標不斷後移,指標反向即可...
linux 鍊錶及相關鍊錶操作
1.鍊錶結構體 struct list head2.list entry define container of ptr,type,member container of ptr,type,member ptr為list head指標,type為包含list head結構體物件型別,member為鍊...