编写一个程序实现顺序表的插入和删除(数据结构)
来源:百度知道 编辑:UC知道 时间:2024/06/17 02:25:08
例如:10 20 30 40 50 60 70 85 90 100 线删除50显示新的队列,在插入65,再显示新的队列。
#include<stdio.h>
#include<malloc.h>
#include<windows.h>//exit要用
#define TURE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVEFLOW -2
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef int Status;
typedef int ElemType;
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(OVEFLOW);
L.length=0;
L.listsize=LIST_INIT_SIZE;
return OK;
}
Status Input_Sq(SqList &L){
printf("Input L.length:\n");
scanf("%d",&L.length);
printf("Input the element:\n");
for(int i=0;i<L.length;i++)
scanf("%d",&L.elem[i]);
return OK;
}
void ListEmpty