资源描述:
《数据结构单链表的建立 数据结构几种排序链表程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、数据结构单链表的建立数据结构几种排序链表程序导读:就爱阅读网友为您分享以下“数据结构几种排序链表程序”的资讯,希望对您有所帮助,感谢您对92to.com的支持!顺序表#include#definemaxlen100typedefstruct{intdata[maxlen];intlistlen;}seqlist;voidprintf1(seqlistL){inti;for(i=0;iprintf(\printf(}voidList_delete(seqlistL,inti){intj;if(L.listlenL.listlen
2、
3、ivoidList_
4、insert(seqlistL,intx,inti){intj;if(L.listlen==maxlen){printf(if(iL.listlen+1){printf(for(j=L.listlen-1;j>=i-1;j--)L.data[j+1]=L.data[j];L.data[i-1]=x;L.listlen++;printf1(L);}6voidmain(){seqlistL;inti,x;L.listlen=0;for(i=0;iscanf(List_insert(L,x,i);scanf(List_delete(L,i);}二叉树排序
5、#include#includestructBnode{intdata;structBnode*lchild,*rchild;};voidinsertbst(Bnode*&t,Bnode*s){if(t==NULL)t=s;elseif(s->datadata)insertbst(t->lchild,s);elseinsertbst(t->rchild,s);}voidinorder(Bnode*t){if(t!=NULL){inorder(t->lchild);printf(\inorder(t->rchild);}}voidmain(){inti
6、,x;Bnode*t=NULL,*s;for(i=1;is=(Bnode*)malloc(sizeof(Bnode));s->data=x;s->lchild=NULL;s->rchild=NULL;printf(insertbst(t,s);}inorder(t);printf(}链表#includestructnode{intdata;6structnode*next;};voidprintf1(node*L){node*p=L->next;printf(while(p!=NULL){printf(\}Voidcreate_List(node
7、*L){node*R,*u;intx;L=(node*)malloc(sizeof(node));R=L;scanf(while(x!=-1){u=(node*)malloc(sizeof(node));u->data=x;R->next=u;R=u;scanf(}R->next=Null}Voidinsert(node*L,inti,intx){node*S,*P=L;intk=0;while(k!=i-1&&P!=Null){P=P->next;k++;}if(P==Null)error(序号错else{S=(node*)malloc(size
8、of(node));S->data=x;S->next=P->next;P->next=S;}}voidmain(){node*L;inti,x;create_List(L);printf1(L);scanf(insert(node*L,inti,intx);printf1(L);}插入排序6#includemain(){inta[11]={0,3,5,16,1,65,32,976,54,877,36};inti,j,temp;for(i=2;iwhile(j>=1&&a[j]>temp){a[j+1]=a[j];j=j-1;}a[j+1]=temp;
9、}for(i=1;i插入排序#includemain(){inta[11]={0};inti,j,temp;for(i=1;iwhile(j>=1&&a[j]>temp){a[j+1]=a[j];j=j-1;}a[j+1]=temp;}for(i=1;i插入排序includemain(){inta[11]={0,3,5,16,1,65,32,976,54,877,36};inti,j;for(i=2;ia[0]){a[j+1]=a[j];j=j-1;}a[j+1]=a[0];}for(i=1;i冒泡排序#includemain(){inta[11]=
10、{0,3,5,16,1,65,32,976,54,877,36},