实验二:栈和队列.ppt

  1. 1、本文档共16页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实验二:栈和队列(一) 打印队列模拟 实验背景 无论是网络上路由器的存储转发还是图的广度优先遍历算法,队列在计算机科学和信息技术中的应用是非常广泛的。 网络上的打印作业的管理应用中要决定用户得到打印服务的优先次序。如果我们按照作业到来的顺序采用先来先服务的策略,那么队列就可以实现这种先来先服务的机制。 实验目标 对队列的理解 对STL中的queue的使用 实验要仿真一个网络打印过程 实验目标 仿真过程要从一个文件中读、处理事件表 Event record(a job)构成 The time (in seconds) The length in pages of the job The name of the computer 从文件中读出后存储在workload(inherited queue) 类 实验目标 实验方案 simulate the passage of time by incrementing a counter A print job “arrives”. pop this event. place it in another queue<event> object. The job waiting in this queue. 工程文件 main.cpp - Includes function main simulator.h - Declaration of class simulator simulator.cpp - Definition of class simulator event.h - Declaration of class event event.cpp - Definition of class event job.h - Declaration of class job 存储结构 job.cpp - Definition of class job arbitrary.run - Data file containing arbitrary print jobs arbitrary.out - Output from a sample solution when run using arbitrary.run bigfirst.run - Data file containing larger jobs first bigfirst.out - Output from a sample solution when run using bigfirst.run void Part::describe(void) declare and implement class fifo. void Part::describe(void) First declare your class fifo in a file named fifo.h. Declare class fifo appropriately to model the following relationship: a fifo is a type of simulator. void Part::describe(void) Next complete the implementation of fifo::simulate. void Part::describe(void) Next This member function should first load the data file using the inherited loadworkload. Then it should implement the simulation as described above. Use the inherited seconds_per_page data member to help determine how long a print job takes to print. Your solution's output should match the output from the sample solutions. void Part::describe(void) latency :作业到来之后等待开始打印的时间 Aggregate latency :所有打印作业的总的等待时间 mean latency:作业的平均等待时间 打印作业状态图 fifo::simulate流程 * * job(); job(int number_of_pages, string user); string getuser() const; int getnumpages() const

文档评论(0)

linsspace + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档