2.10 从顺序表中a中删除第i个元素起的k个元素
#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef int Status;
typedef struct {
int integer;
}ElemType;
typedef struct {
ElemType* elem;
int length;
int listsize;
}SqList;
Status DeletK(SqList* a, int i, int k)
{
//本过程从顺序存储结构的线性表a中删除第i个元素起的k个元素
if (i < 1 || k<0 || i + k>a->length) {
printf("parameters infeasible\n");
return INFEASIBLE;
}
else {
for (int j = i + k; j <= a->length; j++, i++)
{
a->elem[i - 1] = a->elem[i + k - 1];
}
a->length -= k;
}
return OK;
}
int main()
{
SqList a = {
(ElemType*)malloc(LIS