From 3ec839aa53f68daf8fb633d1b3cf7b2dd91b2a63 Mon Sep 17 00:00:00 2001 From: ViolentAyang <76544389+ViolentAyang@users.noreply.github.com> Date: Sun, 6 Mar 2022 11:02:57 +0800 Subject: [PATCH] =?UTF-8?q?Create=20=E7=BA=BF=E6=80=A7=E8=A1=A8=E6=8F=92?= =?UTF-8?q?=E5=85=A5=E6=95=B0=E6=8D=AE.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 线性表/线性表插入数据.c | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 线性表/线性表插入数据.c diff --git a/线性表/线性表插入数据.c b/线性表/线性表插入数据.c new file mode 100644 index 0000000..80ead17 --- /dev/null +++ b/线性表/线性表插入数据.c @@ -0,0 +1,43 @@ +#include +#include +#define MaxSize 10 + +typedef struct{ + int *data; + int length; +}SeqList; + +void ListInsert(SeqList *L,int i,int e){ + for(int j = L->length;j>=i;j--){ + L->data[j] = L->data[j-1]; + } + L->data[i-1] = e; + L->length ++; +} +void InitList(SeqList *L){ + L->data = (int*)malloc(sizeof(int)*MaxSize); + L->length = 0; +} +void PrintList(SeqList L){ + for(int i = 0;i