ImageVerifierCode 换一换
格式:DOCX , 页数:16 ,大小:59.41KB ,
资源ID:19726581      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/19726581.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(数据结构实验Word文档下载推荐.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

数据结构实验Word文档下载推荐.docx

1、Void menu()Bool DelLinkList(LinkList &L,int pos,int &e)5. 调试分析-Configuration: 33 - Win32 Debug-Compiling.11.cppD:AA3311.cpp(6) : error C2146: syntax error : missing ; before identifier data error C2501: ElemType : missing storage-class or type specifiersAA3311.cpp(12) : error C2061: identifier AA331

2、1.cpp(13) :delect_L fatal error C1004: unexpected end of file foundError executing cl.exe.33.exe - 7 error(s), 0 warning(s)6. 使用说明程序名为LinkList.exe,运行环境为DOS。程序执行后显示:2-DELETEPlease Select(2):在Please Select(2):后输入数字选择执行不同的功能。每执行一次功能,就会显示执行的结果(正确或错误)以及执行后单链表的内容。选择2:显示DELETE pos,e=,要求输入要删除的位置,执行成功后返回元素的值

3、。7. 测试结果#includestdlib.hmath.htypedef int Elemtype;typedef struct LNode;ElemType data;struct LNode *next;LNode;LNode *L;LNode *creat_L();void out_L(LNode *L);void insert_L(LNode *L,int i,ElemType e);ElemType delect_L(LNode *L,int i);int locat_L(LNode *L,ElemType e);void main()int i,k,loc;ElemType e,

4、x;char ch;do printf(n); printf(n 1.建立单链表n 2.删除元素n 3.结束程序运行n=n 请输入您的选择(1,2,3) scanf(%d,&k); switch(k) case1:L=creat_L(); out_L(L); break;case2:printf(n请输入要删除元素的位置:i); x=delete_L(L,i); if(x!=-1)printf(n删除的元素为:%dn,x);删除%d后的单链表为: else printf(n要删除的元素不存在! LNode *creat_L() LNode *h,*p,*s; ElemType x; h=(LN

5、ode *)malloc(sizeof(LNode); h-next=NULL; p=h;n请输入第一个数据元素:x); while(x!=-999) s=(LNode *)malloc(sizeof(LNode); s-data=x; p-next=s; p=s;请输入下一个数据:(输入-999表示结束.) return(h); /*creat_L */ void out_L(LNode *L) LNode *p; p=L-next;nn while(p!=NULL) printf(%5d,p-data);p=p- ; /*out_link*/ Elemtype delete_L(LNode

6、 *L,int i) LNode *p,*q;int j;ElemType x; p=L;j=0; while(p-next!=NULL&jj+; if(! p-next|ifree(q); return(x); / *delete_L */实验报告二设计一个程序,用于演示折半查找的查找方法,要求采用菜单的形式进行选择。本程序在TC2.0环境下编写程序,完成折半查找。执行查找操作时,需要输入待查找元素的值。查找操作完成后,若找到待查找元素,则显示该元素在线性表中的位置,反之,给出Cannot find!信息。完成线性表的查找操作。(1)为了实现上述程序功能,需要定义线性表的数据结构。 显示主界

7、面Menu() 查找表的初始化ElemInit() 显示静态查找主界面PrintStaticMenu() 折半查找BinarySearch 主函数main()(3)各函数间的关系如图所示。(1)查找表顺序存储结构和链式存储结构的定义 Typedef struct Keytype key;ElemType;Typedef struct ElemType elemMAX_LIST_LEN+1 Int length;Seq_Table;Seq_Table seqtbl;Typedef struct NODE ElemType elem;Struct NODE*next;LINK_NODE;(2)基本

8、操作。Typedef struct KeyType key; InfoType otherinfo; NodeType;Typedef NodeType Seqlistn+1; ZZ - Win32 Debug-XX.CPPd:aazzxx.cpp(1) : error C2018: unknown character 0xa10xb4 error C2006: #include expected a filename, found identifieraazzxx.cpp(7) : error C2143: before TypedefZZ.exe - 6 error(s), 0 warni

9、ng(s)每执行一次功能,就会显示执行的结果(正确或错误)以及执行后线性表的内容。选择1:静态查找。动态查找。选择0:退出。#includestdio.hconio.hstring.hmalloc.h#define Keytype int#define MAX_LIST_LEN100#define ENDVALUE -1Typedef struct BINNODE Struct BINNODE*lchild,*rchild;BSTNode,*BSTree;/*显示主页面*/Void PrintMenu() printf(nnnnnttt - 各类查找综合演示 - nnttt*nttt* 1-静

10、态查找 *nttt* 2-动态查找 * nttt* 0-退 出 *nttt*nttt请选择功能号(0-2):/*查找表初始化*/Void ElemInit() Int i=1; PrintfLIST_LEN,ENDVALUE); seqtbl.length=0;while(1)scanf(elem.key);if(elem.key= =ENDVALUE)break;else seqtbl.elemi+.key;seqtbl.length+;/*输出查找表的所有元素*/ void output(Seq_Table seqtbl1)int kprintffor(k=1;k=-32768&(x=32

11、767) printf break;return x;/*显示静态查找主界面*/Void PrintStaticMenu()ttt - 静态查找综合演示 - nnttt* 1-折半差找 *printf(nttt* 0-返回主界面 *nttt*nttt请选择功能号(1):Int BinarySearch(Seq_Table Seq_Tbl,Keytype Sea_Key)/*Seq_Tbl为查找表,Seq_Key为待查找的关键字*/int mid, low,high;low=1;high=Seq_Tbl.length;while(low=high) mid=(low+high)/2; if (S

12、eq_Tbl.elmemid.keySeq_Key) high=mid-1if(lowhigh) return 0 return mid;void StaticSearch() char static_func_choice; printStaticMenu(); getchar(); dtatic_func_choice=getchar(); while(static_fun_choice!=0) switch (static_func_choice) case1: int retval,seakey; seakey=input(); printf(n请注意!折半查找要求是有序表,若元素顺序

13、无序,则首先将排序! n BubbleSort(&seqtbl); retval=BinarySearch(seqtbl,seakey); output(seqtbl);nt你要查找的关键字为:,seakey); if(retval0) printf(nt查找成功,关键字为%d的元素位于第个%d位置!,seakey,retval); elsent对不起,关键字为%d的元素不存在.seakey); break; default: printf(n请输入正确的操作选项(1): getchar(); PrintStaticMenu();void DynamicSearch()Keytrpe Ins_

14、key,Sea_Key; BSTree p,root=NULL; char dynamic_func_choice; PrintDynamicMenu(); dynamic_fun_choice=getchar(); while (dynamic_func_choice! switch(dynamic_func_choice) casent请输入要查找的关键字: scanf(Sea_Key); SearchBST(root,Sea_Key); break; printDynamicMenu(); dynamic_func_choice=getchar(); char func_choice;

15、PrintMenu(); func_choice=getchar(); while (fun_choice! switch(func_choice) case StaticSearch(); break;2 DynamicSearch() func_choice= default: printf(实验报告三要求使用自己熟悉的的排序算法,将指定文件中的字符按行进行插入排序。(1)建立文件 建立一个文本文件IN.TXT,输入若干行字符串(文件中的数据可自拟),每个串以回车符结束。(2)算法输入 从文件IN.TET中按行读取字符并存入二维字符数组。(3)算法输出 将排序后的二维字符数组输出到另一个文

16、本文件OUT.TXT中。先将指定文本文件IN.TXT中的数据按行读入一个二维字符数组;然后对该二维字符数组中的字符按行执行直接插入排序和冒泡排序;最后将已排好序的数据按行写入另一个文本文件OUT.TET中。冒泡排序的基本思想是将n个记录看作按纵向排列,每趟排序时自下至上对每对相邻记录进行比较,若次序不符合要求(逆序)就交换。每趟排序结束时都能使排序范围内关键字最小的记录象一个气泡一样升到表上端的对应位置,整个排序过程共进行n-1趟,依次将关键字最小、次小、第三小的各个记录“冒到”表的第一个、第二个、第三个位置上(1)数据类型定义Char xx5080;(2)基本操作Void InsertSor

17、t(SeqList R)int i,j;For(i=2;i=n;i+)R0=Ri;J=i-1;While(R0.keyRj.key/*从右向左有序区R1.i-1中查找Ri的插入位置*/Rj+1=Rj;j-;Rj+1=R0;/*InsertSort*/(3)设文件IN.TXT中数据如下:ISAM enhances the functionality of your programs through itsFlexibility. If you add a section to a book,remove a few pafes,Or rearrange paragraphs or section

18、s,you have to recreate yourIndex,since the keywords must appear in relation to each other is Alphabetic order. A ISAM index changes automatian employee,or 慢慢 - Win32 Debug-解决.cppLinking.LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain16Debug/慢慢.exe : fatal error LNK1120: 1

19、 unresolved externalsError executing link.exe.慢慢.exe - 2 error(s), 0 warning(s)程序运行后文件OUT.TXT中的数据如下:AIMSaaacceeeffgghhhhiiilmnnnnoooooprrrrssstttttuuuyy,.Iaaaaabbcddeeeeeefffgiiiikllmnooooooprsstttuvwxyy,aaaaaaacceeeeeeegghhinnoooooopprrrrrrrrrssstttuuvyy,.aaaaccddeeeeeeeehhhiiiiklmnnnnoooopprrrrssstttt

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1