高手帮忙调成程序,菜鸟求教!!!在线等

来源:百度知道 编辑:UC知道 时间:2024/05/26 12:58:28
我是菜鸟,很简单的线性表的创建插入删除查询,用的wintc,好像只有一个错了我不会弄,高手给运行一下改一下,万分感谢,追分答谢!!!
#include <stdio.h>
#include <malloc.h>
#define LIST_INIT_SIZE 100 /* 线性表存储空间的初始分配量 */
#define LISTINCREMENT 10 /* 线性表存储空间的分配增量 */
typedef struct List{
int *data; /*存储空间基址*/
int length; /*当前长度*/
int listsize; /*当前分配的存储容量*/
}SqList;
void InitList(SqList L) /* 构造一个空的线性表 */
{
L.data=(int *)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.data) printf("ERROR\n"); /* 存储分配失败 */
L.length=0;
L.listsize=LIST_INIT_SIZE;
printf("OK\n");
}/* InitList */
void ListInsert(SqList L,int i,int e) /* 在顺序线性表L中第i个位置之前插入元素 */
{
int *newbase,*q,*p;
if(i<1||i>L.length+1) printf("ERROR\n"); /* i值不合法 */
if(L.length>=L.listsize) /* 已满增加分配 */
{
newbase=(int *)realloc(L.data,(

已经用///////////////////Error1,///////////////////Error2给你标出来了

#include <stdio.h>
#include <malloc.h>
#define LIST_INIT_SIZE 100 /* 线性表存储空间的初始分配量 */
#define LISTINCREMENT 10 /* 线性表存储空间的分配增量 */
typedef struct List{
int *data; /*存储空间基址*/
int length; /*当前长度*/
int listsize; /*当前分配的存储容量*/
}SqList;
void InitList(SqList L) /* 构造一个空的线性表 */
{
L.data=(int *)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.data) printf("ERROR\n"); /* 存储分配失败 */
L.length=0;
L.listsize=LIST_INIT_SIZE;
printf("OK\n");
}/* InitList */
void ListInsert(SqList L,int i,int e) /* 在顺序线性表L中第i个位置之前插入元素 */
{
int *newbase,*q,*p;
if(i<1||i>L.length+1) printf("ERROR\n"); /* i值不合法 */
if(L.length>=L.listsize) /* 已满增加分配 */
{
newbase=(int *)realloc(L.data,(L.listsize+LISTINCREMENT)*sizeof(int));
if(!newbase) printf("ER