MergeList
来源:互联网 发布:mac pro 发热严重 编辑:程序博客网 时间:2024/06/14 08:26
#include<stdio.h>
#include<stdlib.h>
#define MaxSize 50
#define OK 1
#define ERROR 0
typedef int ElemType;
typedef struct
{
ElemType elem[MaxSize];
int length;
}SqList;
int DispList(SqList *L)
{
int i;
if(L->length==0)
{
printf("Blank List!");
return ERROR;
}
for(i=0;i<L->length;i++)
printf("%3d",L->elem[i]);
return OK;
}
void MergeList(SqList *la,SqList *lb,SqList *lc)
{
int i=0;
int j=0,k=0;
while(i<la->length&&j<lb->length)
{
if(la->elem[i]<lb->elem[j])
{
lc->elem[k]=la->elem[i];
i++;
k++;
}
else
{
lc->elem[k]=lb->elem[j];
j++;
k++;
}
}
while (i<la->length)
{
lc->elem[k]=la->elem[i];
i++;
k++;
}
while(j<lb->length)
{
lc->elem[k]=lb->elem[j];
j++;
k++;
}
lc->length=k;
}
void InitList(SqList *L)
{
int i;
printf("Please input the length of SqList:");
scanf("%d",&L->length);
printf("Please input the elements of Sqlist:");
for(i=0;i<L->length;i++)
{
scanf("%d",&L->elem[i]);
}
}
void main()
{
SqList *la,*lb,*lc;
la=(SqList*)malloc(sizeof(SqList));
InitList(la);
lb=(SqList*)malloc(sizeof(SqList));
InitList(lb);
lc=(SqList*)malloc(sizeof(SqList));
MergeList(la,lb,lc);
printf("The elements of after merge between SqList la and SqList lb:");
DispList(lc);
printf("\n");
}
- mergelist
- MergeList
- 合并线性表(MergeList)
- Fix the Problem with MergeList
- Ubuntu故障处理:Problem with Mergelist
- Linux:Problem with MergeList /var/lib/apt/lists
- E:Problem with MergeList /var/lib/apt/lists/cn.archive.ubuntu.com_ubuntu_dists_natty_main_i18n_Translation-en
- E:Encountered a section with no Package: header, E:Problem with MergeList /var/lib/apt/lists/******
- How To Fix “Problem with MergeList /var/lib/apt/lists” Error In Ubuntu 11.04
- ubuntu 解决 “E: Problem with MergeList /var/lib/apt/lists/”错误
- 解决 E:Encountered a section with no Package: header, E:Problem with MergeList /var/ ...
- 数据结构_两条非递减单链表合并成第三条非递减单链表MergeList
- How To Fix “Problem with MergeList /var/lib/apt/lists” Error In Ubuntu 11.04
- ubuntu 解决 “E: Problem with MergeList /var/lib/apt/lists/”错误
- How To Fix “Problem with MergeList /var/lib/apt/lists” Error In Ubuntu 11.04
- ubuntu 解决 “E: Problem wih MergeList /var/lib/apt/lists/”错误
- ubuntu 解决 “E: Problem with MergeList /var/lib/apt/lists/”错误
- E:Encountered a section with no Package: header, E:Problem with MergeList /var/lib/apt/lists/cn.arch
- linux内存管理之uboot第一步
- C#中调用存储过程
- Date.UTC方法的问题
- 关于android:scrollbarStyle属性
- POJ-1416-Shredding Company
- MergeList
- iphone画图
- 【转载】收集到一份中文注释版的PHP.ini配置
- Java中的传值引用和传址引用
- 倒排文件索引(Inverted File Index)的建立
- 音视频即时通讯安全问题的应对策略
- Tomcat启动过程原理详解
- android 语音识别 Recognizer.cpp 源码
- 音轨与声道区别