📄 zn3.cpp
字号:
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include"lstack1.h"
#include"lqueue.h"
const int full=10;
LStack1<int>chargestack;
LStack1<int>tempgestack;
LQueue<int>storequeue;
int sell(LStack1<int> &st){
int j=rand()%full;
int temp1;
for(int i=0; i<j; i++){
st.pop(temp1);
}
return j;
}
int addstore(int pd)
{ cout<<"现在仓库里的货物数量少于50件,进货,填满仓库"<<"\n";
while(storequeue.length()<80)
{storequeue.enqueue(pd);
pd++;
}
return pd;
}
void addcharge()
{ int temp;
cout<<"现在货架上的商品数量少于15件,从仓库运货"<<"\n";
while(chargestack.length()!=0)
{
chargestack.pop(temp);
tempgestack.push(temp);
}
while(tempgestack.length()<20)
{
storequeue.dequeue(temp);
tempgestack.push(temp);
}
while(chargestack.length()<20)
{
tempgestack.pop(temp);
chargestack.push(temp);
}
}
main()
{
int productdate=1;
int storenumber=80;
productdate=addstore(productdate);
addcharge();
cout<<"\n";
cout<<"今天商店关门后货架所剩上的商品的生产日期是"<<"\n";
while(chargestack.play())
{}
cout<<"\n";
cout<<"如果想退出,输入e"<<" ";
char m;
cin>>m;
while(m!='e')
{
if(chargestack.length()<15)
addcharge();
if(storequeue.length()<50)
productdate=addstore(productdate);
cout<<"\n";
sell(chargestack);
cout<<"今天商店关门后货架所剩上的商品的生产日期是"<<"\n";
while(chargestack.play())
{}
cout<<"\n";
cout<<"如果想退出,输入e"<<" ";
cin>>m;
}
cout<<"\n";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -