程序实现的功能:
- 先创建一个长度包含5个元素的顺序表,其表的数据类型为整型;
- 并且把你创建的顺序表元素输出显示;
- 在顺序表的某位置实现插入一个新的数据元素,并显示出新的顺序表。
#include<stdio.h>
#include<stdlib.h>
#define OK 1
#define ERROR 0
#define OVERFLOW -1
#define List_Size 100
#define ListIncrement 10
typedef int ElemType;//typedef double ElemType;
typedef struct{
ElemType *elem;
int length;
int listsize;
}SqList;
int InitList(SqList &L){
L.elem=new ElemType[List_Size];
if(!L.elem)
exit (OVERFLOW);
L.length=0;
return OK;
}
void CreateList(SqList &L,int n){
int i;
printf("请输入%d个元素,构造顺序表\n",n);
for(i=0;i<n;i++){
sc