热门

最新

红包

立Flag

投票

同城

我的

发布
2201_75435309
科院计科212黄录松2103103030
4 年前
true2201_75435309


#include<stdio.h>
#include<malloc.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 100 //顺序表的存储结构定义
#define LISTINCREMENT 10
typedef int ElemType; //假设线性表中的元素均为整型
typedef struct{
ElemType* elem; //存储空间基地址
int length; //表中元素的个数
int listsize; //表容量大小
}SqList; //顺序表类型定义
Status ListInsert_Sq(SqList &L, int pos, ElemType e);
Status ListDelete_Sq(SqList &L, int pos, ElemType &e);
int ListLocate_Sq(SqList L, ElemType e);
void ListPrint_Sq(SqList L);
Status InitList_Sq(SqList &L)//结构初始化与销毁操作
{
L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType)); //初始化L为一个空的有序顺序表
if(!L.elem)exit(OVERFLOW);
L.listsize=LIST_INIT_SIZE;
L.length=0;
return OK;
}
int main() {
SqList L;
if(InitList_Sq(L)!= OK) {
printf("InitList_Sq: 初始化失败!!!\n");
return -1;
}

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
宝娟,我的嗓子
立即登录