全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
课程名称: 数据结构与算法 成绩评定: 湖南第一师范学院信息科学与工程系实验报告实验项目名称: 单链表的基本操作 指导教师: 学生姓名: 沈丽桃 学号: 10403080118 专业班级: 10教育技术 实验项目类型: 验证 实验地点: 科B305 实验时间: 2011 年 10 月20 日一、实验目的与要求: 实验目的:实现线性链表的创建、查找、插入、删除与输出。基本原理:单链表的基本操作 二、实验环境:(硬件环境、软件环境) 1.硬件环境:奔PC。2.软件环境:Windows XP 操作系统,TC2.0或VC。三、实验内容:(原理、操作步骤、程序代码等)#include#include#includestruct celltype int element; struct celltype*next;typedef int position;void main() struct celltype*head,*p; int x,choice; void INSERT(int x,struct celltype*p); void LOCATE(int x,struct celltype*p); void DELETE(int x,struct celltype*p); p=(struct celltype*)malloc(sizeof(struct celltype); head=p; p-element=0; p-next=NULL; printf(“Please option:1:Insert 2:Locate 3:Deleten”); printf(“Please choose:”); scanf(“%d”,&choice); switch(choice) case 1: printf(“Please input a node:”); scanf(“%d”,&x); p=head; INSERT(x,p); for(p=head;p!=NULL;p=p-next) printf(“%d”,p-element); printf(“n”); break; case 2: printf(“Please input the data you want to locate:”); scanf(“%d”,&x); p=head; LOCATE(x,p); break; case 3: printf(“Please input the data you want to delete:”); scanf(“%d”,&x); DELETE(x,p); for(p=head;p!=NULL;p=p-next) printf(“%d”,p-next); printf(“n”); break;void INSERT(int x,struct celltype*p) struct celltype*t,*q; q=(struct celltype*)malloc(sizeof(struct celltype); q-next=x; while(xp-element)&(p!=NULL) t=p; p=p-next; if(xp-element)&(p-next!=NULL) p-next=q; q-next=NULL; else q-next=p; t-next=q; void LOCATE(int x,struct celltype*p) while(p-next!=NULL) if(p-next-element=x) printf(“the number %d is in %dn”,x,p); else printf(“the number not exist!n”); void DELETE(int x,struct celltype*p) while(p-element!=x)&(p-next!=NULL) t=p; p=p-next; if(p-element=x) t-next=p-next error C2018:unknown character Oxalerror C2065:Please:undeclared identifiererror C4024:printf:different types for formal and actual parameter 1error C4047:function:const*differs in levers of indirection from interror C2146:syntaxerror:missing)before identifieroptionerror C2017:illegal escape sequenceerror C2059:syntax error:)error C2143:syntax error:missing)before% 出现了很多错误,主要是因为printf里的一对双引号不是英文状态下的。将双引号改好后,错误消失,输入时应注意细节,最好直接在编译环境下输程序error C2043:illegal breakerror C2043:illegal caseerror C2198:scanf:too few actual parameters这里是由于每一个case间应有缩进,或者用大括号括起来。error C2065:t:undeclared identifierwarning C4047:=:struct celltype*differs in levers of indirection这个错误是p-next=x,应改为p-element=xerror C2223:left of-nextmust point to struct/union 这里是由于t没有定义,还有最后一个语句后没有分号。四、实验体会 注意细节,像拼写错误就该避免,要注意所有符号必须是英文状态下的。所有变量必须定义清楚,在用switch语句时,注意每
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 金蝉脱壳策略解析苏教版
- 苏教版八年级上册生物探索生命的奥秘
- 信息技术教学总结4
- 二年级数学计算题专项练习1000题汇编集锦
- 《电子商务数据分析基础》课件-模块二 基础数据采集
- 怎样提高幼儿美术的创作能力
- 医院培训课件:《艾滋、梅毒、乙肝感染孕妇分娩婴儿防治措施》
- 2024年南京客运资格证考试题库下载
- 2024年新疆考客运资格证需要什么条件
- 2024年石家庄客运上岗证考什么内容
- 跨学科实践活动1 微型空气质量“检测站”的组装与使用课件-2024-2025学年九年级化学人教版(2024)上册
- 2024年湖南省中考英语试题卷(含答案)
- 新公司法及公司章程修订专题讲座课件
- 大学团支书竞选ppt
- 磷石膏堆场项目库区工程施工组织设计(171页)
- 度假酒店温泉部操作手册(含表格)
- NB_T 10333-2019《水电工程场内交通道路设计规范》_(高清最新)
- 简约道路行驶安全教育交通安全知识培训讲座通用PPT模板
- 酒文化典故:贺知章金龟换酒
- 车间尾料零头管理制度
- 声动力进展ppt课件
评论
0/150
提交评论