{
j = Max_date(a, i); temp = a[j]; a[j] = a[i-1]; a[i-1] = temp; } }
/*打印商品信息*/
void Goods_print(SeqStack *s) { int i; int count; count=s->top+1; if(count==0)
printf(\货架上共有%d件商品。\\n\\n\else {
printf(\货架上共有%d件商品。\\n\\n\ printf(\ printf(\生产日期 *\\n\
printf(\ for(i=count-1;i>=0;i--) {
printf(\ printf(\ }
} }
/*商品上架*/
void Goods_in(SeqStack *s) {
char choice; int jishu; int num1; struct Goods Gd; do
if(s->top==MAXSIZE-1)
{printf(\对不起,货架已满。\\n\ return; } else {
printf(\请输入商品的数量,生产日期:\ scanf(\ /*
do {
printf(\请输入生产日期(1-12整数):\ scanf(\ }
while(Gd.date<1 || Gd.date>12);*/
for(jishu=0;jishu Push_SeqStack(s,Gd); //商品入架 Goods_arrange(s->data,s->top+1); //按时间排序 printf(\商品入架成功\\n\ printf(\是否继续商品入架?\\n(1.继续,任意键否):\ scanf(\ } while(choice=='1'); } /*商品出售*/ void Goods_out(SeqStack *s) { char choice; struct Goods Gd; do if(Empty_SeqStack(s)) { printf(\对不起,货架已经无商品.\\n\ return; } else { system(\ Pop_SeqStack(s,&Gd); printf(\卖出商品的信息:\\n\ printf(\ printf(\生产日期 *\\n\ printf(\ printf(\ printf(\ printf(\货架信息:\\n\ Goods_print(s); printf(\是否继续销售商品?\\n(1.继续;任意键否):\ scanf(\ } while(choice=='1'); } void main_menu() { printf(\商品货架管理系统*****************\\n\\n\printf(\商品入架 *\\n\printf(\商品销售 *\\n\printf(\货架查看 *\\n\printf(\} int main() { SeqStack *s1; char flag; int choice1; s1=Init_SeqStack(); while(flag!=Esc) { main_menu(); do { printf(\请选择(1-3):\ scanf(\ } while(choice1<1||choice1>3); switch(choice1) { case 1:system(\ while(choice1!=1); if(choice1==1)Goods_in(s1); break; case 2:system(\ while(choice1!=2); if(choice1==2) Goods_out(s1); break; case 3: system(\ while(choice1!=3); if(choice1==3) { system(\ Goods_print(s1); } break; } printf(\任意键返回,Esc键退出!\ flag=getch(); if(flag==Esc) break; system(\} } return 0;