谁告诉我数据结构c有什么用

来源:百度知道 编辑:UC知道 时间:2024/07/03 02:22:38
那些教科书上的程序用turbo c或wintc编译也没用啊,报错,那我写的程序到底是有什么作用呢,加描述?哪位给我一个数据结构的c程序,我用wintc编译下,谢谢

很多数据结构书上的程序代码都只是“算法”是不能直接在编译器里面进行编译的,需要加一些内容,下面就是我写的顺序表的操作函数等:
#include <stdio.h>
#include <malloc.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
typedef int status;
typedef int ElemType;

//定义顺序表的数据类型
#define LIST_INIT_SIZE 100 //线性表存储空间的初始化分配量
#define LISTNICREMENT 10 //线性表存储空间的分配增量
typedef struct{
ElemType *elem; //存储空间基址
int length; //当前长度
int listsize; //当前分配的存储容量(以sizeof(ElemType)为单位)
}SqList;

status InitList_Sq(SqList &L)
{//创建一个新的线性表
L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
L.listsize=LIST_INIT_SIZE;
L.length=0;
return OK;
}//initList_Sq

status DestroyList_Sq(SqList &L)
{//销毁线性表L
free(L.elem);
L.length=0;
L.listsize=0;
return OK;
}//DestroyList_Sq

status ClearList_Sq(SqList &L)
{//清空线性表L
L.length=0;
retur