描述:
La和Lb是两个从小到大 排序的链表,对La进行插入节点,删除节点,修改节点值操作,最后合并La和Lb,合并后仍然按从大到小排列
代码
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 100
#define OK 1
#define ERROR -1
typedef int Status;
typedef int ElemType;
typedef struct SqList{
ElemType *Elem_array;
int length;
}SqList;
//初始化顺序表
Status Init_SqList(SqList *L){
L->Elem_array = (ElemType*)malloc(MAX_SIZE * sizeof(ElemType));
if(!L->Elem_array)
return ERROR;
else{
L->length = 0;
return OK;
}
}
Status Traverse_SqList(SqList *L){
int i;
if(L->length == 0){
printf("线性表为空.");
return ERROR;
}
else{
for(i = 0; i < L->length; i++){
printf("%d\t", L->Elem_array[i]);
}
}
return OK;
}
Status Insert_SqList(Sq