问题及代码:
/*
* Copyright(c) 2016, 烟台大学计算机与控制工程学院
* All rights reserved.
* 文件名称:
* 作 者:陈梦雪
* 完成日期:2016年 9月 18日
* 版 本 号:v1.0
*
* 问题描述: 删除元素在[x, y]之间的所有元素,要求算法的时间复杂度为O(n),空间复杂度为O(1);
* 输入描述:无
* 程序输出:删除后的表
*/
头文件list.h代码:
#ifndef LIST_H_INCLUDED
#define LIST_H_INCLUDED
#define MaxSize 50
#include <stdio.h>
#include <malloc.h>
typedef int ElemType;
typedef struct
{
ElemType data[MaxSize];
int length;
} SqList;
void CreateList(SqList *&L, ElemType a[], int n);//用数组创建线性表
void InitList(SqList *&L);//初始化线性表InitList(L)
void DestroyList(SqList *&L);//销毁线性表DestroyList(L)
bool ListEmpty(SqList *L);//判定是否为空表ListEmpty(L)
int ListLength(SqList *L);//求线性表的长度ListLength(L)
void DispList(SqList *L);//输