顺序表基本操作的实现 实验报告(《数据结构》适用)实验一 顺序表、单链表基本操作的实现.doc
文本预览下载声明
顺序表基本操作的实现 实验报告(《数据结构》适用)实验一 顺序表、单链表基本操作的实现
肇庆学院 计算机学院/软件学院
实 验 报 告
专业 计算机科学与技术 班级 科技1班 姓名 付治齐 学号 201324131151 课程名称 数据结构
学年 学期 1? / 2□ 课程类别 专业必修? 限选□ 任选□ 实践□ 评分: 批阅老师: 2014年 10月 30 日 实验一 顺序表、单链表基本操作的实现
? 实验目的
1、顺序表
(1)掌握线性表的基本运算。
(2)掌握顺序存储的概念,学会对顺序存储数据结构进行操作。
(3)加深对顺序存储数据结构的理解,逐步培养解决实际问题的编程能力。
2、链表
(1)掌握链表的概念,学会对链表进行操作。
(2)加深对链式存储数据结构的理解,逐步培养解决实际问题的编程能力。
? 实验内容
1、顺序表
(1)编写线性表基础操作问题。
(2)调用上述函数实现基础的线性表操作。
(3)
……
2、链表
(1)编写链表基础操作函数。
(2)调用上述函数实现链表的基础操作。
(3)
……
? 实验结果
1、顺序表
(1)画出数据结构基本运算的流程图
(2)程序运行主要结果截图
(3)程序源代码
#includelt;stdio.hgt;
#includelt;stdlib.hgt;
#includelt;malloc.hgt;
struct LinearList
{
};
typedef struct LinearList LIST; void InitList(LIST *L,int ms) {
}
int InsertList(LIST *L,int item,int rc) {
int *list; int size; int MaxSize; if((L-gt;list=(int*)malloc(ms *sizeof(int)))==NULL){ } L-gt;size=0; L-gt;MaxSize=ms; printf(内存申请错误!\n); exit(1); int i; if(L-gt;sizegt;=L-gt;MaxSize) return-1; if(rclt;0) rc=0; if(rcgt;L-gt;size) rc=L-gt;size;
}
for(i=L-gt;size-1;igt;=rc;i--) L-gt;list[i+1]=L-gt;list[i]; L-gt;list[rc]=item; L-gt;size++; return 0;
void OutputList(LIST *L) {
}
int FindList(LIST *L,int item) {
}
int DeleteList1(LIST *L,int item) {
int i; for(i=0;ilt;L-gt;size;i++) printf(%d ,L-gt;list[i]); printf(\n); int i; for(i=0;ilt;L-gt;size;i++) if(item==L-gt;list[i]) return i; return -1; int i,n; for(i=0;ilt;L-gt;size;i++) if(item==L-gt;list[i]) break; if(ilt;L-gt;size){
}
} for(n=i;nlt;L-gt;size-1;n++) L-gt;list[n]=L-gt;list[n+1]; L-gt;size--; return i; return -1;
int DeleteList2(LIST *L,int rc) {
}
void main()
{
int i,n; if(rclt;0||rcgt;=L-gt;size) return -1; for(n=rc;nlt;L-gt;size-1;n++) L-gt;list[n]=L-gt;list[n+1]; L-gt;size--; return 0; LIST LL; int i,r; printf(list addr=%p\tsize=%d\tMaxSize=%d\n,LL.list,LL.size,LL.MaxSize); InitList(LL,100); printf(list addr=%p\tsize=%d\tMaxSize=%d\n,LL.list,LL.siz
显示全部