不知道那个地方错了,输入6次操作结果还未输入完成程序就已经结束

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
#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 SIZE 1000
typedef int ElemType;
typedef int Status;
#define len 10
typedef struct 
{
    ElemType* elem;
    int length;
    int listsize;
}SqList;
Status InitList(SqList& L)
{
    L.elem = (ElemType*)malloc(sizeof(ElemType) * SIZE);
    if (!L.elem)
    {
        exit(OVERFLOW);
    }
    L.length = 0;
    L.listsize = SIZE;
    return OK;
}
void Clear(SqList& L)
{
    L.length = 0;
}
int compare(ElemType a, ElemType b)
{
    if (a==b)
    {
        return 1;
    }
    return 0;
}
int LocateElem(SqList L, ElemType e,int (*compare)(ElemType,ElemType))
{
    int i = 1;
    ElemType* p;
    p = L.elem;
    while (i<=L.length&&!(*compare)(*p++,e))
    {
        i++;
    }
    if (i<=L.length)
    {
        return i;
    }
    else
    {
        return 0;
    }
}
void  GetElem(SqList L, int i, ElemType& e)
{
    e = L.elem[i - 1];
}
Status ListInsert(SqList& L, int i, ElemType e)
{
    ElemType* newbase;
    if (i<1||i>L.length+1)
    {
        return ERROR;
    }
    if (L.length>=L.listsize)
    {
        newbase = (ElemType*)realloc(L.elem, (L.listsize + len) * sizeof(ElemType));
        if (!newbase)
        {
            exit(OVERFLOW);
        }
        L.elem = newbase;
        L.listsize += len;
    }
    ElemType* p;
    for (int j = L.length-1; j >= i-1; j--)
    {
        L.elem[j + 1] = L.elem[j];
    }
    L.elem[i - 1] = e;
    L.length++;
    return OK;
}
Status ListDelete(SqList& L, int i, ElemType& e)
{
    if (i<1||i>L.length)
    {
        return ERROR;
    }
    if (L.length==0)
    {
        return ERROR;
    }
    e = L.elem[i - 1];
    for (int j =i-1 ; j < L.length-1; j++)
    {
        L.elem[j] = L.elem[j + 1];
    }
    L.length--;
    return OK;
}
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    SqList L;
    if (InitList(L))
    {
        for (int i = 0; i < n; i++)
        {
            scanf("%d", &L.elem[i]);
            L.length++;
        }
        char a;
        int b;
        while(m--)
        {
            scanf("%c%d", &a, &b);
            if (a=='D')
            {
                ElemType e;
                ListDelete(L, b, e);
                printf("%d\n", e);
            }
            if (a=='G')
            {
                ElemType e;
                GetElem(L, b, e);
                printf("%d\n", e);
            }
            if (a=='L')
            {
                ElemType e;
                e = b;
                printf("%d\n", LocateElem(L, e, compare));
            }
            if (a=='I')
            {
                ElemType e;
                scanf("%d", &e);
                ListInsert(L, b, e);
            }
            if (a=='C')
            {
                Clear(L);
            }
        }
    }
    return 0;
}

Input

第一行有两个整数n,m分别表示初始线性表的长度和操作的个数,下面有m行,每一行都是上面5个操作中的一个。

Output

输出操作要求的输出。

Sample Input
5 6
1 2 3 4 5
D 3
D 1
G 1
G 2
G 3
L 4