软件技术基础上机实验报告_顺序表.doc

软件技术基础上机实验报告_顺序表.doc

ID:52141401

大小:121.00 KB

页数:7页

时间:2020-03-23

软件技术基础上机实验报告_顺序表.doc_第1页
软件技术基础上机实验报告_顺序表.doc_第2页
软件技术基础上机实验报告_顺序表.doc_第3页
软件技术基础上机实验报告_顺序表.doc_第4页
软件技术基础上机实验报告_顺序表.doc_第5页
资源描述:

《软件技术基础上机实验报告_顺序表.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、软件技术基础上机实验报告姓名:肖燕平学号:2011019090028上机实验一Exl_l#include#definemaxnum20typedefstructlist_type{intdata[maxnum];intlength;}list_type;voiderror(inta){switch(a){case0:printf「thelengthofthedataistoolongH);break;case1:printfC^ntheplaceiswrong'n”);break;}}voidcreatlist(list_type*table)〃创建链表{inti;

2、intk;table->length=O;printf(HpleaseinputthenumbersofthedataH);for(i=0;idata[i]=k;table->length++;}while(k!=-l)〃如果数据输入过长,则报错且重新输入数据{error(O);while(k!=-l)〃防止接下来的程序变量得到错误的数据{scanf(”%d”,&k);}creatlist(table);}}voidshowlist(list_type*table)〃显

3、示数据{inti;while(table->length<=O){printf("NODATA");creatlist(table);}for(i=0;ilength;i++){printf("%d",table->data[i]);}printf("thelengthofthedatais%d"ztable->length);}voidinsertlist(list_type*table,intplazintnum)//插入一个数{inti;while(pla<011pla>table->length)//如果插入的位置不符合条件,则重新输入error(l);pri

4、ntfC'npleaseinputtheplaceoftheinsertnumberagain");scanf(”%d”,&pla);}table->length=table->length-l;pla=pla-l;for(i=table->length;i>pla-l;i-){table->data[i+l]=table->data[i];}table->data[pla]=num;table->length=table・>length+2;}voiddelete」ist(list_type*table,intplace)〃删除一个数{inti;while(place>table->l

5、ength-l11placelength-l;i++){table->data[i]=table->data[i+l];}table->length~;}voidmain(){intinse_placejnse_num;intdel_place;list_typetable;creatlist(&table);〃创建顺序表showlist(&table);〃显示顺序表p

6、rintf(HpleaseinputtheinsertplaceandnumberrV');scanf(H%d%dH/&inse_place/&inse_num);insertlist(&table,inse_place,inse_num);〃插入一个数printf(HthenewlistisM);showlist(&table);//显示插入数后的顺序表printf(Hpleaseinputthedeleteplace”);scanf("%d",&del_place);delete_list(&table,del_place);〃删除一个数printf("then

7、ewlistis");showlist(&table);输出数据:1,不考虑边界情况■飞:欢件技朮基亡完戒誌.朕序表的豆入与5]涂'liaodan.ex*pleaseinputthenumbersofthedata12-34567-8-90-112-34567-8-90thelengthofthedatais10pleaseinputtheinsertplaceandnunber48thenewlist

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。