数据结构程序(c语言描述)!!!急急急!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/28 03:00:46
顺序表的基本操作
以数字型数据元素为例,完成顺序表的基本操作.操作包括初始化,清空,建立,按序号查找,插入,排序.所有操作由菜单控制完成.

我做到以下程序 在就做不出来了
编译的时候有两次错误

#include "stdio.h"
#include "conio.h"
#define size 100
#define elemtype int
#define NULL 0
typedef struct Node
{
int elem[size];
int length;
struct Node* next;
int listsize;
}Sqlist;
int Sq(Sqlist *L)
{
L=(Sqlist)malloc(sizeof(elemtype)); /*初始化*/
if(L->elem!=NULL)
L->length=0;
L->listsize=size;
return 1;
}
void clearlist(Sqlist *L)
{ /*清空*/
L->length=0;
printf("the Sqlist is empty");
}
void Sq1(Sqlist *L) /*建立*/
{
if (L->elem!=NULL)
L->length=0;
L->listsize=size;
printf("hcreat is complete");
}
void getdate(Sqlist *L,int i,j,ElemType *e) /*按序号查找*/
{
i=0;
while((i<L.

线性表,即顺序表
#include<stdio.h>
#include<stdlib.h>
#define LIST_INIT_SIZE 100 //线性表存储空间初始分配量
#define LISTINCREMENT 10 //线性表存储空间分配增量
typedef struct
{
int *elem; //存储空间基址
int length; //当前长度
int listsize; //当前分配存储容量
}SqList;

void InitList(SqList *L) //初始化
{
L->elem = (int *)malloc(LIST_INIT_SIZE * sizeof(int));
if(!L->elem) exit(1);
L->length = 0;
L->listsize = LIST_INIT_SIZE;
}

int GetElem(SqList *L,int i) //取得i位置的元素
{
if(i<1 || i>L->length) exit(1);
return (L->elem[i-1]);
}

void ListInsert(SqList *L,int i,int e) //插入
{
//顺序线性表L中第i个位置之前插入新元素e
int *newbase,*q,*p;
if(i<1 || i>L->length+1) exit(1);
if(L->length>=L->listsize) //存储空间满,增加分配