明天就要交了!!!~~!~1求程序:1.用C语言完成顺序表的插入和删除:2.用C语言完成链表的插入和删除

来源:百度知道 编辑:UC知道 时间:2024/05/27 17:26:00
最好完整些哈~
麻烦大家调试了以后再贴哈~~谢了哈 ~插入和删除在一个程序里实现的~

随便找一本数据结构的习题集,上面多的是。
/*
表的顺序实现(插入操作保持)
author: kk.h
date: 2006.9
http://www.cocoon.org.cn
*/

#include "stdio.h"
typedef struct{
int no;
int grade;
}ElemType;

typedef struct{
ElemType *elem;
int length;
int listsize;
}SqList;

int InitList(SqList *pL)
{
pL->listsize = 10;
pL->elem = (ElemType*)malloc(pL->listsize*sizeof(ElemType));
pL->length=0;
}
DestroyList(SqList *pL)
{
free(pL->elem);
}
int ListInsert(SqList *pL,ElemType e)
{
int i,j;
if (pL->length>=pL->listsize){
pL->listsize = pL->listsize + 10;
pL->elem = (ElemType *)realloc(pL->elem,(pL->listsize)*sizeof(ElemType));
}

/*找插入点的位置*/
for(i=0;i<pL->length;i++){