商品货架管理_第1页
商品货架管理_第2页
商品货架管理_第3页
商品货架管理_第4页
商品货架管理_第5页
已阅读5页,还剩12页未读, 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、西安郵電學院数据结构课内实验报告题 目:商品货架管理院系名称:专业名称:班 级:学生姓名:学号(8位):一. 需求分析本程序的任务:设计一个商品货架管理 系统,要求:(1):利用栈和队列去设计(2):栈顶的生产日期最早,栈底的最晚,上货架的时候,是生产 日期较近的在较下的的位置。(3):输入值的范围:日期大于20100302,个数小于7,必须按照 由小到大的顺序输入(3):功能:要进行货架的周转二. 概要设计1.功能模块图;push()函数的流程图:In把s1中的商品信息传递到s2中sl-top-Pop(s1); Pop(s2)把New结束11开始s2-top真s2;t op+循环输出,s1栈

2、中商品出栈s1-top !=-1 &New.输循环Pop函数的流程图:main()函数流程图:2.各个模块的功能描述。push()函数功能:往栈中输入信息In sert()函数功能:插入新的信息Pop()函数功能:输出栈中的信息。三. 详细设计数据类型struct in formatio nchar n ame10;long date;;typedef structstruct information goodssize;int top;seqstack;int TOP;struct information New;seqstack s1,s2;伪码算法push():for(i=1;i

3、top+;scanf(%s%d,,&s1-goodss1-top.date);if(s1-goodss1-top.date top = -1;for(;s1-top!=-1 & New.date s1-goodss1-top.dates1-top-)s2-top+;strcpy(,);s2-goodss2-top = s1-goodss1-top;s1-top+;strcpy(,N);s1-goodss1-top.

4、date=New.date;for(;s2-top!=-1 &s2-goodss2-top.date=N;s2-top-)s1-top+;strcpy(,);s1-goodss1-top.date = s2-goodss2-top.date;Pop():for(;s1-top!=-1;s1-top-)printf(%9s%10dn,,s1-goodss1-top .date);the goods in the s1:(原栈)函数调用关系图:四. 时间复杂度分析push()函

5、数的时间复杂度为:O(s1-toP);Insert()函数的时间复杂度为:O (2*s1-top+1);Pop()函数的时间复杂度为:O(s1-top+1);所以整个程序的时间复杂度为:0(4*s1-toP+2);五. 测试数据及运行结果(1):正常的输入:red 20110302wer 20110205 dio 20100605 ree 20100203输入新的商品信息:die 20100708正常的运行结果:出栈!出栈!reediower 20110205red 20110302dio 20100605 ree 20100203die进栈!dio进栈!print the informati

6、on of thesegoods :dio 20100605 die 20100708 wer20110205 red 20110302(2) :非正常 的输入:乱序输入:red 20110303 wed 20110403 wds 20110506 res20100203输入新的商品信息:idd 20110308非正常的 运行结果 :res出栈!the goods in the s2: (辅助栈)wds 20110506 wed 20110403red 20110303res 20100203进栈!print the in formati on of these goods:idd 20110

7、308 wds 20110506 wed 20110403 red 20110303出现排序混乱的现象六. 调试情况,设计技巧及体会1.进栈的时候应该先输入生产日期最早的的商品,而且对于生产日期应该有更精确的限制,应该使用队列解决此问题。对于非正常输入应该有 所判断。2.对设计及调试过程的心得体会。设计过程中使我对于对列和栈有了更好的认识,不过程序设计不够完美,考虑不全,还有些问题,所以以后应该对于程序有更好的考虑。七.附录:源代码,包括注释#in cludethe goods in the s1:(原栈)the goods in the s2:(辅助栈)idds1-to p二-1;#incl

8、udevstri ng.h#defi ne size 7struct in formatio nchar n ame10;long date;typ edef structstruct in formati on goodssize;/the nuMber of pu tedint top;seqstack;int p ush(seqstack *s1);intIn sert(seqstack*s1,struct informati onNew,seqstack *s2);void Pop( seqstack *s1);/进栈int p ush(seqstack *s1)int i;print

9、f(n put into the goods information:(date 20100302 , nu mber top-)for(i=1;it op+;sca nf(%s%d,s1-goodss1-t op.n ame,& s1-goodss1-t op.date);if(s1-goodss1-t op .date top;/插入NeWint Insert(seqstack*s1,structinformationNew,seqstack *s2)int m,n;s2-t op二-1;& New.date s1-goodss1-top.datefor(;s1-to p!

10、=-1s1-t op+;s2-t op+;prin tf(%s出栈!n,s1-goodss1-t op . name);strc py (s2-goodss2-t op.n ame,s1-goodss1-t );/先出后进s2-goodss2-t op二s1-goodss1-t op;m=s1-t op;n=s2-t op;p ri ntf(nthe goods in the s1:(Pop( s1);p ri ntf(the goods in the s2:(Pop (s2);s1-to p=m;s2-t op二n;s1-t op+;strc py(s1-goodss1-t o

11、p.n ame,New. name);s1-goodss1-to p.date二New.date;printf(n%s进栈!n,N);for(;s2-t op!=-1 & s2-goodss2-to p .date=N;s2-to p-)原栈)n);辅助栈)n);prin tf(%s进栈!n,s2-goodss2-t op . name);strc py (s1-goodss1-t op.n ame,s2-goodss2-t );s1-goodss1-t op .date = s2-goodss2-t op .date;return s1-top;/输出栈void Pop( seqstack * s1)for(;s1-to p!=-1;s1-to p-)pri ntf(%9s%10dn,s1-goodss1-t op.n ame,s1-goodss1-top .date);int main (void)int TOP;struct in formati on New;seqstack s1,s2;p ri ntf(nthe goods man ageme nt!n);TOP二p ush(&s1);printf(put into the new information

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论