资源预览内容
第1页 / 共5页
第2页 / 共5页
第3页 / 共5页
第4页 / 共5页
第5页 / 共5页
亲,该文档总共5页全部预览完了,如果喜欢就下载吧!
资源描述
实验一、有序表的建立、插入和删除一、实验目的:1、 了解有序表的顺序存储结构。2、 掌握有序表元素在内存中是怎么存储的。3、 在有序表中实现如下操作:1) 插入一个新元素到第 i 个位置,使原来标号为增一;2) 删除第 i 个位置的元素;3) 存一个新元素到第 i 个位置;4) 读表;5) 检索表中第 i 个元素;6) 寻表的长度;二、实验步骤:1、 参考实验程序自己编出的程序,上级调试。2、 对调试好的程序进行以下实验:当机器显示表长时,可以渐入一个小于 100 的整数,然后根据功能表做:1:表示有序表的插入;2:表示有序表的删除;3:表示存新值;4:表示检索第 i 个元素;5:表示查表长;三、参考程序:#includestatic int array100;int j,i,n,p;int ch;void du()printf(please tell me which number do you operate:);scanf(%d,while(in)printf(error,please input again);scanf(%d,void da()printf(the list is);for(j=0;j=0&p=i-1;j-)arrayj+1=arrayj;printf(please enter number:);scanf(%d,arrayi-1=ch;n+;da();break;case 2:du();for(j=i-1;j=n;j+)arrayj=arrayj+1;n-;da();break;case 3:du();printf(please enter new element:n);scanf(%d,printf(n);arrayi-1=ch;da();break;case 4:da();break;case 5:du();printf(what is the %d number:,i);printf(%3dn,arrayi-1);break;case 6:printf(the length of the list is:);printf(%3dn,n);break;case 0:p=0;break;printf(error,please enter new number);四、运行结果:
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号