| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 533 人关注过本帖
标题:顺序表的合并(纯小白)
取消只看楼主 加入收藏
抓狂的程序员
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-10-29
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
顺序表的合并(纯小白)
#include "stdio.h"
#include "malloc.h"
#define OK 1
#define OVERFLOW -1
#define ERROR 0
#define LIST_INIT_SIZE 100
#define LISTINCREMENT  10
typedef int ElemType;
typedef int Status;

typedef  struct{
ElemType  *elem;
int  length;
int  listsize;
}sqlist;

Status InitList_sq(sqlist *L){
L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L.elem) exit(OVERFLOW);
L.length=0;
L.listsize=LIST_INIT_SIZE;
return OK;
}

void MergeList_Sq(SqList La,SqList Lb,SqList &Lc){
pa=La.elam;pb=Lb.elem;
Lc.listsize=Lc.length=La.length+Lb.length;
pc=Lc.elem=(ElemType *)malloc(Lc.listsize*sizeof(ElemType));
if(!Lc.elem)exit(OVERFLOW);
pa_last=La.elem+La.length-1;
pb_last=Lb.elem+Lb.length-1;
while(pa<=pa_last&&pb<=pb_last){
if(*pa<=*pb)*pc++=pa++;
else*pc++=*pb++;
}
while(pa<=pa_last)*pc++=*pb++;
while(pb<=pb_last)*pc++=*pb++;
}
这些都是算法?还需要一个主程序?然后再怎么弄、呃、就学C语言的时候敲过三两个程序、真心不懂、求指教、帮忙写完、谢谢、
搜索更多相关主题的帖子: include return 
2013-10-29 15:40
抓狂的程序员
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-10-29
收藏
得分:0 
回复 2楼 yuccn
谢谢大斑竹、就是main函数不知道怎么引用 结构、 我们初学过C语言、然后学的数据结构、感觉学的接不上。。

抓狂的新手程序员、
2013-10-29 17:17
快速回复:顺序表的合并(纯小白)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016571 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved