电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

数据结构上机题VIP免费

数据结构上机题_第1页
1/25
数据结构上机题_第2页
2/25
数据结构上机题_第3页
3/25
数据结构上机题 //1、设有两个有序序列,利用归并排序将它们排成有序表,并输出。 #include"stdio.h" #include"stdlib.h" #define LIST_INIT_SIZE 100 #define LISTINCREMENT 10 #define OVERFLOW -2 #define OK 1 typedef struct { int *elem; int length; int listsize; }SqList; int InitList_Sq(SqList &L) {L.elem=(int *)malloc(LIST_INIT_SIZE*sizeof(int)); if(!L.elem)exit(OVERFLOW); L.length=0; L.listsize=LIST_INIT_SIZE; return OK; } void MergeList_Sq(SqList La,SqList Lb,SqList &Lc) {int *pa,*pa_last,*pb,*pb_last,*pc; pa=La.elem; pa_last=La.elem+La.length-1; pb=Lb.elem; pb_last=Lb.elem+Lb.length-1; Lc.listsize=Lc.length=La.length+Lb.length; pc=Lc.elem=(int*)malloc(Lc.listsize*sizeof(int)); if(!Lc.elem)exit(OVERFLOW); while(pa<=pa_last&&pb<=pb_last) {if(*pa<=*pb)*pc++=*pa++; else *pc++=*pb++; } while(pa<=pa_last)*pc++=*pa++; while(pb<=pb_last)*pc++=*pb++; } int Input(SqList &L) { int i,j; int *pa=L.elem; printf("要输入的元素个数:"); scanf("%d",&i); printf("输入有序序列:"); for(j=0;j #include #define OK 1 #define ERROR -1 #define OVERFLOW -2 #define LIST_INIT_SIZE 100 typedef struct{ int *elem; int length; int listsize; }SqList; int InitList_Sq(SqList &L){ L.elem=(int *)malloc(LIST_INIT_SIZE*sizeof(int)); if(!L.elem) exit(OVERFLOW); L.length=0; L.listsize=LIST_INIT_SIZE; return OK; } int ListInsert_Sq(SqList &L, int i,int e){ if((i<1)||(i...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

数据结构上机题

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部