表的3个例子
1.线性表的例子
#include "List.h" int data[5] = {2, 3, 6, 7, 11}; int main(void) { //线性表的简单示例 int i, j, k; SQLIST L; k = InitSqlist(&L, 10); //初始化线性表 if(k == 0) { puts("ERROR"); exit(-1); } for(i = 0; i < 5; ++i) AppendSqlistElem(&L, data[i]); //把data数据放入线性表 TraverseSqlist(L); //遍历线性表 putchar(10); j = SearchSqlist(L, 6); //查找数据6 DeleteSqlistElemAt(&L, j); //删除 InsertSqlistElemAt(&L, 5, j); //插入5 TraverseSqlist(L); DestroySqlist(&L); //销毁线性表 return 0; }
2.单链表的例子
#include "List.h" int data[5] = {2, 3, 6, 7, 11}; int main(void) { //链表示例 int i, j, k; LINKLIST L = NULL; NODEPTR S, SPRE; k = InitLinklist(&L); //初始化链表 if(k == 0) { puts("ERROR"); exit(-1); } for(i = 0; i < 5; ++i) AddLinklistElem(L, data[4-i]); //添加数据 TraverseLinklist(L); //遍历 putchar(10); DeleteLinklistElem(L, 6); //删除元素6 InsertLinklistElemAt(L, 5, 3); //插入元素5 TraverseLinklist(L); DestroyLinklist(&L); //释放表 return 0; }
3.双向链表的例子
#include "List.h" int data[5] = {2, 3, 6, 7, 11}; int main(void) { //双向链表的简单示例 int i, j, k; DBLINKLIST L; DBNODEPTR t; k = InitDBLinklist(&L); //初始化双向链表 if(k == 0) { puts("ERROR"); exit(-1); } for(i = 0, t = L; i < 5; ++i,t = t->next) InsertDBLinklistElemAfter(t, data[i]); //把data数据放入双向链表 TraverseDBLinklist(L); //遍历双向链表 putchar(10); t = SearchDBLinklist(L, 6); //找到6 DeleteDBLinklistElem(t); //删除6 t = SearchDBLinklist(L, 3); //找到3 InsertDBLinklistElemAfter(t, 5); //插入5 TraverseDBLinklist(L); DestroyDBLinklist(&L); //销毁双向链表 return 0; }
2020年3月20日 04:20
I often benefit from finding a website that serves up wonderful info as I like finding out new things. Frequently that I have been to this web site I've really liked the good article on this website. I will be certain to watch out for the following article.. Thanks for the wonderful post I am going to revisit in the future. south korea call forwarding
2020年4月02日 03:54
Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing... 메이저토토사이트
2020年4月02日 04:59
These websites are really needed, you can learn a lot. 먹튀검증사이트
2020年4月03日 22:15
I also wrote an article on a similar subject will find it at write what you think. 바카라사이트
2022年1月08日 15:32
The Jawahar Navodaya Vidyalaya (JNV) Samiti has also successfully completed the lateral entry admission selection tests for vacant seats of Class 7th, 8th, 9th, 10th, 12th Grade admission selection tests. A huge number of students are participated in lateral entry exam and the students are waiting to check JNV Result 2022 District Selected list Navodaya Result 2022 Class 6 along with waiting listed student details for all rural and urban area schools across in the state.Navodaya Vidyalaya Samity is announced the 5th to 6th Class Result for the listed regions or zones in district wise for all rural and urban area school of the country in roll number wise along with the name of the student.