#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef int Status;
//顺序表的存储结构定义
#define LIST_INIT_SIZE 11
#define LISTINCREMENT 10
typedef int ElemType; //假设线性表中的元素均为整型
typedef struct
{
ElemType *elem; //存储空间基地址
int length; //表中元素的个数
int listsize; //表容量大小
} SqList; //顺序表类型定义
Status InitList_Sq(SqList &L)
{
//初始化L为一个空的有序顺序表
L.elem = (ElemType *)malloc(LIST_INIT_SIZE * sizeof(ElemType));
if (!L.elem)
exit(OVERFLOW);
L.listsize = LIST_INIT_SIZE;
L.length = 0;
return OK;
}
Status ListInsert_Sq(SqList &L, int pos, ElemType e)
{
if (L.length == L.listsize)
{
ElemType *tmp = (ElemType *)realloc(L.elem, (L.listsize + LISTINCREMENT) * sizeof(ElemType));
if (!tmp)
exit(OVERFLOW);
L.elem = tmp;
}
if (pos > L.length + 1 || pos < 1)
{
return ERROR;
}
for (int i = L.length; i > pos - 1; i--)
{
L.elem[i] = L.elem[i - 1];
}
L.elem[pos - 1] = e;
L.length++;
return OK;
}
Status ListDelete_Sq(SqList &L, int pos)
{
for (int i = pos - 1; i < L.length; i++)
{
L.elem[i] = L.elem[i + 1];
}
L.length--;
return OK;
}
void ListPrint_Sq(SqList L)
{
for (int i = 0; i < L.length - 1; i++)
{
printf("%d ", L.elem[i]);
}
printf("%d\n", L.elem[L.length - 1]);
}
int main()
{
SqList L;
if (InitList_Sq(L) != OK)
{
printf("InitList_Sq: 初始化失败!!!\n");
return -1;
}
int n = 0;
int tmp = 0;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
scanf("%d", &tmp);
ListInsert_Sq(L, i, tmp);
}
ElemType min = 0, max = 0;
scanf("%d", &min);
scanf("%d", &max);
// if (min > max)
// {
// tmp = min;
// min = max;
// max = tmp;
// }
for (int i = 0; i < L.length;)
{
if (min <= L.elem[i] && L.elem[i] <= max)
{
ListDelete_Sq(L, i + 1);
}
else
{
i++;
}
}
ListPrint_Sq(L);
return 0;
}