#include <stdio.h>
#include <stdlib.h>
typedef struct{
int *elements;
size_t size;
size_t capacity;
}SequentialList;
//创建顺序表
void SequentialListInit(SequentialList *list,int capacity){
list->elements = (int*)malloc(sizeof(int)*capacity);
list->size = 0;
list->capacity=capacity;
}
//顺序表的销毁
void SequentialListDestroy(SequentialList *list){
if(list->elements){
free(list->elements);
list->elements = NULL;
}
}//获取顺序表的大小,该接口直接获取顺序表的成员变量size并返回
size_t SequentialListSize(const SequentialList *list){
return list->size;
}//顺序表的插入操作
void SequentialListInsert(SequentialList *list,int index,int element){
if(index<0||index>list->size){
printf("Invalid index \n");
return ;
}
if(list->size == list->capacity){
int *newElements = (int *)realloc (list->elements,sizeof(int)*list->capacity*2);
if(newElements