#include
#include
#define ERROR 0
#define OK 1
typedef int Status;
typedef int ElemType;//顺序表测试用
const int MaxSize=100; //100只是示例性的数据,可以根据实际问题具体定义
const int Increasement=10;
typedef struct{
ElemType *elem;
int length;
int listsize;
}SeqList;
Status InitList(SeqList &a,int n=MaxSize)
{//初始化线性表
if(n<=0)
n=MaxSize;
a.elem =(ElemType *)malloc(n*sizeof(ElemType));
if(a.elem ==NULL)
exit(ERROR);
a.length =0;
a.listsize =n;
return OK;
}
Status Deletek(SeqList &a,int i,int k) {//从顺序存储结构的线性表a中删除第i个元素起的k个元素??//注意i的编号从0开始??
int j;
if(ia.length-1||ka.length-i) return ERROR; for(j=0;j<=k;j++)
a.elem[j+i]=a.elem[j+i+k]; a.length=a.length-k; return OK;
}
void main()
{
SeqList La;
ElemType data;
printf("输入顺序表La的元素值:\n");
for(int i=1;i<=10;i++)
{
scanf("%d",&data);
}
InitList(La,10);
Deletek(La,3,5);
}好像main函数有问题,但我不会改