單鏈表各種操作

2021-05-28 15:00:06 字數 791 閱讀 5835

終於自己寫出了關於單鏈表的操作,而不是看別人的,現在程式設計越來越有感覺了,自己編更好,別人的還看不懂,不知道他們的思路是什麼

單鏈表的建立,插入,刪除,排序,求長度。插入是按大小順序插入的。

#include #include struct node

;void creat(node * );

void print(node * );

int length(node *);

void insert(node *, int );

void del(node *, int);

void sort(node *,int);

void main()

void creat (node * head)

creat(a);

}void sort(node* a,int len) //交換資料,而不是指標

p=p->next;

q=q->next;}}

}void insert(node * a, int val) // 按大小順序插入

void del(node * a, int val)

p=p->next;

}p->next=p->next->next; }

void print(node* a)

printf("\n");

}int length(node * a)

n=n-1;

return n;

}

對於其他的資料結構就是struct的結果不同吧

單鏈表的各種操作

單鏈表的各種操作 define null 0 typedef char elemtype 字元型資料 typedef struct lnode setnull struct lnode p int length struct lnode p elemtype get struct lnode p,i...

單鏈表的各種操作

單鏈表的各種操作 define null 0 typedef char elemtype 字元型資料 typedef struct lnode elemtype data struct lnode next setnull struct lnode p int length struct lnode...

單鏈表的各種操作

單鏈表的各種操作 define null 0 typedef char elemtype 字元型資料 typedef struct lnode setnull struct lnode p int length struct lnode p elemtype get struct lnode p,i...