全文预览

华南农业大学数据结构上机实验指导书及答案

上传者:徐小白 |  格式:doc  |  页数:173 |  大小:697KB

文档介绍
(SqList&L){?inti;?for(i=0;i<L.length;i++) printf("%d",L.elem[i]);?printf("\n");?returnOK;}intListLength(SqListL){?returnL.length;}intGetElem(SqListL,inti,ElemType&e){?e=L.elem[i-1];?returnOK;}intListInsert_Sq(SqList&L,inti,inte){?if(i<1||i>L.length+1) returnERROR;?ElemType*p,*q,*newbase;?if(L.listsize<=L.length)?{ newbase=(ElemType*)realloc(L.elem,(L.listsize+LISTINCREMENT)*sizeof(ElemType)); L.elem=newbase; L.listsize+=LISTINCREMENT;?}?q=&(L.elem[i-1]);?for(p=&(L.elem[L.length-1]);p>=q;p--) *(p+1)=*p;?*q=e;?L.length++;?returnOK;}voidMergeList(SqListLa,SqListLb,SqList&Lc){?inti,j,k,La_len,Lb_len,ai,bj;?i=j=1;?k=0;?InitList_Sq(Lc);?La_len=ListLength(La);?Lb_len=ListLength(Lb);?while((i<=La_len)&&(j<=Lb_len))?{ GetElem(La,i,ai); GetElem(Lb,j,bj); if(ai<=bj) { ListInsert_Sq(Lc,++k,ai); i++; }

收藏

分享

举报
下载此文档