list.cpp
#ifndef LIST_H_INCLUDED
#define LIST_H_INCLUDED
/*
* Copyright (c) 2015, 烟台大学计算机与控制工程学院
* All rights reserved.
* 文件名称:main.cpp,hanshu.cpp,list.h
* 作者:徐吉平
* 完成日期:2015年9月20日
* 版本号:code ::Block 13.12
*
* 问题描述:删除元素在[x, y]之间的所有元素,要求算法的时间复杂度为O(n),空间复杂度为O(1);
* 输入描述:无
* 程序输出:线性表的结果
*/
#include <stdio.h>
#include <malloc.h>
#define MaxSize 50 //Maxsize将用于后面定义存储空间的大小
typedef int ElemType; //ElemType在不同场合可以根据问题的需要确定,在此取简单的int
typedef struct
{
ElemType data[MaxSize]; //利用了前面MaxSize和ElemType的定义
int length;
}SqList;
void delx2y(SqList *&L, ElemType x, ElemType y);
void InitList(SqList *&L);//初始化链表
void CreateList(SqList *&L, ElemType a[], int n);//用数组创建线性表
bool ListInsert(SqList *&L,int i,ElemType e) ;//插入数据元素ListInsert(L,i,e)
int ListLength(SqList *L);//求线性表的长度ListLength(L)
bool GetElem(SqList *L,int i,ElemType &e);