鍊錶的C語言實現(七)

2021-03-31 22:53:42 字數 847 閱讀 1753

在這裡列舉了乙個應用單鏈表基本演算法的綜合程式,雙向鍊錶和迴圈鍊錶的綜合程式大家可以自己去試一試。

#include

#include

#include

#define n 10

typedef struct node

stud;

stud * creat(int n)

h->name[0]='/0';

h->link=null;

p=h;

for(i=0;ilink=s;

printf("請輸入第%d個人的姓名",i+1);

scanf("%s",s->name);

s->link=null;

p=s;

}return(h);

}stud * search(stud *h,char *x)

if(p==null)

printf("沒有查詢到該資料!");

}stud * search2(stud *h,char *x)

}if(p==null)

printf("沒有查詢到該資料!");

}void insert(stud *p)

printf("/n請輸入你要插入的人的姓名:");

scanf("%s",stuname);

strcpy(s->name,stuname);

s->link=p->link;

p->link=s;

}void del(stud *x,stud *y)

void print(stud *h)

}void quit()

void menu(void)

main()}}

鍊錶的C語言實現

編輯 c巨集例項 以下 摘自linux核心2.6.21.5原始碼 部分 展示了鍊錶的另一種實現思路,未採用ansi c標準,採用gnu c標準,遵從gpl版權許可。struct list head define list head init name define list head name st...

雙向鍊錶C語言實現

ifndef stdlist h define stdlist h typedef struct tagstdnode stdnode,lpstdnode typedef struct tagstdlist stdlist,lpstdlist 鍊錶資料結構 struct tagstdnode 鍊錶節...

線性鍊錶 C語言實現

include include define error 0 define ok 1 define equal 1 define overflow 1 define list init size 100 define listincrement 10 struct stustu 50 typedef...