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

开通VIP
 

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

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

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(软件工程数据结构实验指导书.doc)为本站上传会员【二***】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

软件工程数据结构实验指导书.doc

1、软件工程数据结构实验指导书(完整版) (文档可以直接使用,也可根据实际需要修改使用,可编辑 欢迎下载) 给大家的实验文档中分为一下几部分 1.实验准备:其中是c++的一些内容,希望大家能借此好好复习c++。因为大家现在使用的教材是c++版本的,所以,对于c++的一些基本语法,程序的编写都需要有些了解 2.c语言实验教案中是一些c语言的基础知识,包括VC环境的使用和程序的调试,希望对c语言已经忘记的同学好好看看复习一下。(程序的编写调试是长年累月的过程,需要不断的积累,写得多了,程序调试的多了,自然就熟练了) 3.对应的flash课件:其中是一些实验的flash课件演示,给大家做一下参

2、考 4.实验指导书和实验教案大家在做每个实验前都需要看看。阅读的时候,可以使用【视图】|【文档结构图】,可以比较自由跳到相应位置 5. 总体实验难度比较大,时间紧,单靠实验课上的几个学时,作为初学者是无法完成的,需要大家在课前课后尽自己最大的努力。 实验一 栈和队列(2学时) 实验二 多项式加减法(2学时) 实验三 迷宫(4学时) 实验四 二叉树(4学时) 实验五 图(2学时) 实验六 归并排序(2学时) Programming Project one :Application of Stack & Queue 一、实验目的 通过几段代码的编写,熟悉栈和队列 二、实

3、验内容 1、Reversing a list (必做,分3个小题目task1,task2,task3) 2、Small airport simulation(选作) 具体如下: Task 1: Compile and run the following sample application of stack from the text. You may need to make changes to the code if necessary. Write down your input and output. // Section 2.1: Reversing a Li

4、st #include int main( ) /* Pre: The user supplies an integer n and n decimal numbers. Post: The numbers are printed in reverse order. Uses: The STL class stack and its methods */ { int n; double item; stack numbers; // declares and initializes a stack of numbers cout << " T

5、ype in an integer n followed by n decimal numbers." << endl << " The numbers will be printed in reverse order." << endl; cin >> n; for (int i = 0; i < n; iCC) { cin >> item; numbers.push(item); } cout << endl << endl; while (!numbers.empty( )) { cout << numbers.top( ) << " "; numbers.pop

6、 ); } cout << endl; } Task 2: Assemble the appropriate declarations from the text into the files stack.h and stack.cpp. Make any necessary changes as re-compiling the above application Reversing a List by replacing the use of STL class stack with the use of user defined class Stack. //

7、 Section 2.2: const int maxstack = 10; // small value for testing class Stack { public: Stack(); bool empty() const; Error_code pop(); Error_code top(Stack_entry &item) const; Error_code push(const Stack_entry &item); private: int count; Stack_entry entry[max

8、stack]; }; Error_code Stack::push(const Stack_entry &item) /* Pre: None. Post: If the Stack is not full, item is added to the top of the Stack. If the Stack is full, an Error_code of overflow is returned and the Stack is left unchanged. */ { Error_code outcome = succ

9、ess; if (count >= maxstack) outcome = overflow; else entry[count++] = item; return outcome; } Error_code Stack::pop() /* Pre: None. Post: If the Stack is not empty, the top of the Stack is removed. If the Stack is empty, an Error_code of underflow i

10、s returned. */ { Error_code outcome = success; if (count == 0) outcome = underflow; else --count; return outcome; } Error_code Stack::top(Stack_entry &item) const /* Pre: None. Post: If the Stack is not empty, the top of the Stack is returned in item. If

11、the Stack is empty an Error_code of underflow is returned. */ { Error_code outcome = success; if (count == 0) outcome = underflow; else item = entry[count - 1]; return outcome; } bool Stack::empty() const /* Pre: None. Post: If the Stack is empty, t

12、rue is returned. Otherwise false is returned. */ { bool outcome = true; if (count > 0) outcome = false; return outcome; } Stack::Stack() /* Pre: None. Post: The stack is initialized to be empty. */ { count = 0; } Task 3: Assume the following definition file fo

13、r an extended stack data structure. class Extended_stack { public: Extended_stack(); Error_code pop(); Error_code push(Stack_entry item); Error_code top(Stack_entry &item) const; bool empty() const; void clear(); // Reset the stack to be empty. bool full() const ; //

14、If the stack is full, return true; else return false. int size() const; // Return the number of entries in the stack. private: int count; Stack_entry entry[maxstack]; }; Implement the following methods: (a) clear (b) full (c) size Use method size of the class Extended_stack in

15、 your application Reversing a List to display the number of decimal numbers you imputed. Task 4: Combine all the functions and methods for the airport simulation into a complete program. Experiment with several sample rums of the airport simulation, adjusting the values for the expected numbers

16、of planes ready to land and take off. Find approximate values for these expected numbers that are as large as possible subject to the condition that it is very unlikely that a plane must be refused service. What happens to these values if the maximum size of the queues is increased or decreased?

17、/* Program extracts from Chapter 3 of "Data Structures and Program Design in C++" by Robert L. Kruse and Alexander J. Ryba Copyright (C) 1999 by Prentice-Hall, Inc. All rights reserved. Extracts from this file may be used in the construction of other programs, but this code will

18、 not compile or execute as given here. */ // Section 3.3: const int maxqueue = 10; // small value for testing class Queue { public: Queue(); bool empty() const; Error_code serve(); Error_code append(const Queue_entry &item); Error_code retrieve(Queue_entry &item) const

19、 protected: int count; int front, rear; Queue_entry entry[maxqueue]; }; Queue::Queue() /* Post: The Queue is initialized to be empty. */ { count = 0; rear = maxqueue - 1; front = 0; } bool Queue::empty() const /* Post: Return true if the Queue is empty,

20、otherwise return false. */ { return count == 0; } Error_code Queue::append(const Queue_entry &item) /* Post: item is added to the rear of the Queue. If the Queue is full return an Error_code of overflow and leave the Queue unchanged. */ { if (count >= maxqueue) return overflow

21、 count++; rear = ((rear + 1) == maxqueue) ? 0 : (rear + 1); entry[rear] = item; return success; } Error_code Queue::serve() /* Post: The front of the Queue is removed. If the Queue is empty return an Error_code of underflow. */ { if (count <= 0) return underflow;

22、 count--; front = ((front + 1) == maxqueue) ? 0 : (front + 1); return success; } Error_code Queue::retrieve(Queue_entry &item) const /* Post: The front of the Queue retrieved to the output parameter item. If the Queue is empty return an Error_code of underflow. */ { i

23、f (count <= 0) return underflow; item = entry[front]; return success; } int Extended_queue::size() const /* Post: Return the number of entries in the Extended_queue. */ { return count; } // Section 3.5: int main() // Airport simulation program /* Pre: The user

24、must supply the number of time intervals the simulation is to run, the expected number of planes arriving, the expected number of planes departing per time interval, and the maximum allowed size for runway queues. Post: The program performs a random simulation of the airport, s

25、howing the status of the runway at each time interval, and prints out a summary of airport operation at the conclusion. Uses: Classes Runway, Plane, Random and functions run_idle, initialize. */ { int end_time; // time to run simulation int queue_limit;

26、 // size of Runway queues int flight_number = 0; double arrival_rate, departure_rate; initialize(end_time, queue_limit, arrival_rate, departure_rate); Random variable; Runway small_airport(queue_limit); for (int current_time = 0; current_time < end_time; current_time++) { //

27、 loop over time intervals int number_arrivals = variable.poisson(arrival_rate); // current arrival requests for (int i = 0; i < number_arrivals; i++) { Plane current_plane(flight_number++, current_time, arriving); if (small_airport.can_land(current_plane) != succ

28、ess) current_plane.refuse(); } int number_departures= variable.poisson(departure_rate); // current departure requests for (int j = 0; j < number_departures; j++) { Plane current_plane(flight_number++, current_time, departing); if (small_airpor

29、t.can_depart(current_plane) != success) current_plane.refuse(); } Plane moving_plane; switch (small_airport.activity(current_time, moving_plane)) { // Let at most one Plane onto the Runway at current_time. case land: moving_plane.land(cu

30、rrent_time); break; case takeoff: moving_plane.fly(current_time); break; case idle: run_idle(current_time); } } small_airport.shut_down(end_time); } enum Runway_activity {idle, land, takeoff}; class Runway { public: R

31、unway(int limit); Error_code can_land(const Plane ¤t); Error_code can_depart(const Plane ¤t); Runway_activity activity(int time, Plane &moving); void shut_down(int time) const; private: Extended_queue landing; Extended_queue takeoff; int queue_limit; in

32、t num_land_requests; // number of planes asking to land int num_takeoff_requests; // number of planes asking to take off int num_landings; // number of planes that have landed int num_takeoffs; // number of planes that have taken off int num_lan

33、d_accepted; // number of planes queued to land int num_takeoff_accepted; // number of planes queued to take off int num_land_refused; // number of landing planes refused int num_takeoff_refused; // number of departing planes refused int land_wait;

34、 // total time of planes waiting to land int takeoff_wait; // total time of planes waiting to take off int idle_time; // total time runway is idle }; enum Plane_status {null, arriving, departing}; class Plane { public: Plane(); Plane(int

35、flt, int time, Plane_status status); void refuse() const; void land(int time) const; void fly(int time) const; int started() const; private: int flt_num; int clock_start; Plane_status state; }; void initialize(int &end_time, int &queue_limit, dou

36、ble &arrival_rate, double &departure_rate) /* Pre: The user specifies the number of time units in the simulation, the maximal queue sizes permitted, and the expected arrival and departure rates for the airport. Post: The program prints instructions and initializes the parameters

37、 end_time, queue_limit, arrival_rate, and departure_rate to the specified values. Uses: utility function user_says_yes */ { cout << "This program simulates an airport with only one runway." << endl << "One plane can land or depart in each unit of time." << endl; cout

38、 << "Up to what number of planes can be waiting to land " << "or take off at any time? " << flush; cin >> queue_limit; cout << "How many units of time will the simulation run?" << flush; cin >> end_time; bool acceptable; do { cout << "Expected number of arri

39、vals per unit time?" << flush; cin >> arrival_rate; cout << "Expected number of departures per unit time?" << flush; cin >> departure_rate; if (arrival_rate < 0.0 || departure_rate < 0.0) cerr << "These rates must be nonnegative." << endl; else

40、 acceptable = true; if (acceptable && arrival_rate + departure_rate > 1.0) cerr << "Safety Warning: This airport will become saturated. " << endl; } while (!acceptable); } Runway::Runway(int limit) /* Post: The Runway data members are initialized to record no

41、 prior Runway use and to record the limit on queue sizes. */ { queue_limit = limit; num_land_requests = num_takeoff_requests = 0; num_landings = num_takeoffs = 0; num_land_refused = num_takeoff_refused = 0; num_land_accepted = num_takeoff_accepted = 0; land_wait = takeo

42、ff_wait = idle_time = 0; } Error_code Runway::can_land(const Plane ¤t) /* Post: If possible, the Plane current is added to the landing Queue; otherwise, an Error_code of overflow is returned. The Runway statistics are updated. Uses: class Extended_queue. */ {

43、 Error_code result; if (landing.size() < queue_limit) result = landing.append(current); else result = fail; num_land_requests++; if (result != success) num_land_refused++; else num_land_accepted++; return result; } Error_code Runway::can_

44、depart(const Plane ¤t) /* Post: If possible, the Plane current is added to the takeoff Queue; otherwise, an Error_code of overflow is returned. The Runway statistics are updated. Uses: class Extended_queue. */ { Error_code result; if (takeoff.size() < queue_lim

45、it) result = takeoff.append(current); else result = fail; num_takeoff_requests++; if (result != success) num_takeoff_refused++; else num_takeoff_accepted++; return result; } Runway_activity Runway::activity(int time, Plane &moving) /* Post:

46、If the landing Queue has entries, its front Plane is copied to the parameter moving and a result land is returned. Otherwise, if the takeoff Queue has entries, its front Plane is copied to the parameter moving and a result takeoff is returned. Otherwise,

47、 idle is returned. Runway statistics are updated. Uses: class Extended_queue. */ { Runway_activity in_progress; if (!landing.empty()) { landing.retrieve(moving); land_wait += time - moving.started(); num_landings++; in_progress = land; landing.ser

48、ve(); } else if (!takeoff.empty()) { takeoff.retrieve(moving); takeoff_wait += time - moving.started(); num_takeoffs++; in_progress = takeoff; takeoff.serve(); } else { idle_time++; in_progress = idle; } return in_progress;

49、 } Plane::Plane(int flt, int time, Plane_status status) /* Post: The Plane data members flt_num, clock_start, and state are set to the values of the parameters flt, time and status, respectively. */ { flt_num = flt; clock_start = time; state = status; cou

50、t << "Plane number " << flt << " ready to "; if (status == arriving) cout << "land." << endl; else cout << "take off." << endl; } Plane::Plane() /* Post: The Plane data members flt_num, clock_start, state are set to illegal default values. */ { flt_num =

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服