实验1 线性表及其应用实验报告

上传人:woxinch****an2018 文档编号:39301681 上传时间:2018-05-14 格式:DOCX 页数:9 大小:139.98KB
返回 下载 相关 举报
实验1 线性表及其应用实验报告_第1页
第1页 / 共9页
实验1 线性表及其应用实验报告_第2页
第2页 / 共9页
实验1 线性表及其应用实验报告_第3页
第3页 / 共9页
实验1 线性表及其应用实验报告_第4页
第4页 / 共9页
实验1 线性表及其应用实验报告_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《实验1 线性表及其应用实验报告》由会员分享,可在线阅读,更多相关《实验1 线性表及其应用实验报告(9页珍藏版)》请在金锄头文库上搜索。

1、暨暨南大学本科南大学本科实验报实验报告告专专用用纸纸课程名称 数据结构 成绩评定 实验项目名称 线性表及其应用 指导教师 王晓明 实验项目编号 实验一 实验项目类型 综合性 实验地点 南海楼 601 学生姓名 朱芷漫 学号 2010051875 学院 信息科学技术学院 系 计算机 专业 计算机科学与技术 实验时间 2011 年 9 月 7 日 18:30 午9 月 7 日 20:30 午温度 湿度 一、实验目的和要求实验目的:熟练掌握线性表基本操作的实现及应用 实验要求:在上机前写出全部源程序完毕并调试完毕。二、实验原理和主要内容1.建立 4 个元素的顺序表 SqList=2,3,4,5,实现

2、顺序表的基本操作;在 SqList=2,3,4,5的元素 4 与 5 之间插入一个元素 9,实现顺序表插入的基本 操作;在 SqList=2,3,4,9,5中删除指定位置(i=3)上的元素,实现顺序表删 除的操作。 2.利用顺序表完成一个班级的一个学期的课程的管理:能够增加、删除、修改 学生的成绩记录。三、主要仪器设备PC 机,Windows XP 操作平台,Visual C+四、 调试分析学生课程管理系统的调试过程中发现一些错误,主要是参数设置的问题,经过 修改,错误得到排除。五、 测试结果1. 顺序表2. 学生课程管理系统附录(源程序)1.顺序表的操作#include #define TR

3、UE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define INFEASIBLE -1 #define OVERFLOW -2typedef int Status;typedef int ElemType; #define LIST_INIT_SIZE 10 #define LISTINCREMENT 2typedef struct shunxubiao ElemType *list; int size; int Maxsize; SqList;int InitList_Sq(SqList if (!L.list) return OVER

4、FLOW; / 存储分配失败L.size = 0; / 长度 为 0L.Maxsize = LIST_INIT_SIZE; / 初始存储容量return OK; / InitList_Sqint InsertList_Sq(SqList if (i L.Maxsize+1) return ERROR; q = / q 指示插入位置for (p= p = q; -p) *(p+1) = *p;/ 插入位置及之后的元素右移*q = e; / 插入 e +L.size; / 表长增 1return OK; / ListInsert_Sqint LocateElem_Sq(SqList L, Elem

5、Type e) / 在顺序表中查询数据元素 e,若存在,则返回它的位序,否则返回 0 int i = 1; / i 的初值为第 1 元素的位序 ElemType *p = L.list; / p 的初值为第 1 元素的存储位置while (i 0 p = / p 为被删除元素的位置 e = *p; / 被删除元素的值赋给 e q = L.list+L.size-1; / 表尾元素的位置for (+p; p count; for(int i=0;iL.listi; +L.size; void Print_Sq(SqList coutef; if(!InsertList_Sq(myList,e,f

6、,g) coutwx; if(!ListDelete_Sq(myList,wx,sc) cout #include #include using namespace std; const int LIST_INIT_SIZE=3; const int LISTINCREMENT=5; struct student int StuNum;int CouNum; int Score; char *name; ; class StuCourse student *L; int length; int listsize; public: StuCourse(); void ListAdd(studen

7、t e); void ListDelete(int i); void ListRewrite(student e); void ListPrint(int i); void ListPrintAll(); void copy(student *a,student *b); ; StuCourse:StuCourse() L=new studentLIST_INIT_SIZE; if(!L) coutStuNumStuNum=e.StuNum) coutt;n-)copy(L+n,L+n-1); copy(L+t,length+; void StuCourse:ListDelete(int i)

8、 int t; for(t=0;tStuNum!=i;t+); if(t=length)coutStuNum!=e.StuNum;t+); if(L+t)-StuNum=e.StuNum) copy(L+t, elsecoutStuNum!=i;t+); if(L+t)-StuNum!=i)coutStuNumnameCouNumScoreStuNumnameCouNumScoreStuNum=b-StuNum; a-CouNum=b-CouNum; a-Score=b-Score; a-name=b-name; void write(int a,char *p,int b,int c,stu

9、dent d.name=p; d.CouNum=b; d.Score=c; int main() int i,j,k,n=0; student e; char c=a; char name5020; StuCourse ClassA;while(c!=qClassA.ListPrint(i);getch();break;case c: case C: coutinamenjk;write(i,namen,j,k,e);ClassA.ListAdd(e);n+;getch();break; case d: case D: couti;ClassA.ListDelete(i);getch();break;case e: case E: coutinamenjk;write(i,namen,j,k,e);ClassA.ListRewrite(e);n+;getch();break; case q: case Q:break; default:cout“错误选择“endl;getch(); system(“cls“); return 0;

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号