数据结构顺序表
来源:百度知道 编辑:UC知道 时间:2024/05/14 18:53:57
设计一个静态数组存储结构的顺序表类,要求编程实现如下任务:建立一个线性表,首先依次输人数据元素1,2,3,…,10,然后删除数据元素6,最后依次显示当前线性表中的数据元素。要求采用顺序表实现,假设该顺序表的数据元素个数在最坏情况下不会超过50个。
不知道这个程序能不能满足你的要求,该程序用顺序表方式,能实现删除线性表的元素,之后还可以往线性表中插入元素,后附有运行情况图:
程序如下
#include<iostream>
using namespace std;
#include<malloc.h>
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
#define OVERFLOW -1
#define OK 1
#define ERROR 0
typedef int Status;
typedef int ElemType;
typedef int KeyType;
typedef struct{
ElemType *elem;
KeyType *key;
int length;
int listsize;
}SqList;
typedef struct{
KeyType key;
}SElemType;
Status InitList (SqList &L){