文档介绍:商品货架管理
1、需求分析:设计一个算法,每一次上货后始终保持生产日期越近的商品越靠近栈底。求货架上剩余货物M、每天销售件数N、员工每天上货工作时间T,三者之间有何关系及T的最小值。
2、源程序:#include<>
#include""
#include""
const int maxsize=100;
const int k=10;
#define elemtype char
typedef struct
{
int Month;
int Day;
int Year;
}DATE;
typedef struct
{
int num;
DATE date;
} Node;
class seqstack
{
public:
Node stack[maxsize];
int top;
void inistack()
{
top=0;
}
void push(int x,int day,int month,int year)
{
if(top==maxsize)
cout<<"货架已满"<<endl;
else
{
top++;
stack[top].num=x;
stack[top].=day;
stack[top].=month;
stack[top].=year;
}
}
void pop()
{
if(top==0)
cout<<"货架已空"<<endl;
else
top--;
}
elemtype gettop()
{
if(top==0)
cout<<"货架已空"<<endl;
else
return top;}
bool empty()
{
return top==0;
}
};
void main()
{
seqstack c[k+1]; //存放k种商品的数组,用c[0]来做中介货架
int Txq[k+1]; //第i种取货用的时间
int Txs[k+1]; //第i种上货用的时间
int Nx[k+1]; //第i种每天的销售数量
int N=0; //每天销售总量
int Tx[k+1]; //第i种每天上货的总时间
int T=0; //每天上货用的总时间
char yn='Y';
for(int i=1;i<=k;i++)
{
cout<<" ******************************"<<endl;
cout<<" 商品货架管理系统"<<endl;
cout<<" ******************************"<<endl;
Node store[20];
char year,month;
int count; //货架上第i种商品的数目
int x,d,m,y; //x为第i种商品的序号
cout<<"请输入货架上第"<<i<<"种货物的详细信息:"<<endl;
cout<<"(序号,生产日期(年、月、),现在货架上的存货数目,上货用时和取货用时)"<<endl;
cin>>x>>y