C++模拟超市排队的程序。

等待一个顾客到的时间是随机1~4分钟,顾客购物完成花的时间也是随机1~4分钟,采用队列的数据结构,编写一个程序,模拟12小时。求队列最长有多长?顾客等待最久时间?将1~4换成1~3?

haozai4130 2021-09-19 09:31 330 次浏览 赞 158

最新问答

  • 爱美食小雅

    这是我自己写的一个C++模拟超市收银系统你可以拿去参考一下,基本功能都已经实现了,你可以做一些小的修改如有帮助谢谢采纳。//模拟超市pos机实现销、检索、库存、结算功能#include#include#include#include#includeusingnamespacestd;//定义产品类classproduct{public:voidput();voidsell();voidsearch();voidall();voidjiesuan();voidcmd();private:intid;stringname;intprice;intnumber;};//类的实现//入库实现voidproduct::put(){fstreaminfile;infile.open("txt.txt",ios_base::out|ios_base::app);if(!infile)cout>id;cout>name;cout>price;cout>number;infileid>>name>>price>>number;coutsetw(8)>>id>>setw(8)>>name>>setw(3)>>price>>setw(4)>>number;coutsetw(8)>>id>>setw(8)>>name>>setw(3)>>price>>setw(4)>>number;//coutch;switch(ch){case'a':one.all();//查看库存break;case'r':one.put();//入库break;case'j':one.jiesuan();//结算break;case'z':one.search();//查找break;case's':one.sell();//销break;case'c':one.cmd();//查看指令break;case'e':break;default:cout<<"输入错误,请重新输入!\n"<

    浏览 362赞 121时间 2022-02-22

C++模拟超市排队的程序。

等待一个顾客到的时间是随机1~4分钟,顾客购物完成花的时间也是随机1~4分钟,采用队列的数据结构,编写一个程序,模拟12小时。求队列最长有多长?顾客等待最久时间?将1~4换成1~3?