商品销售
货架查看
4.结论
在本次课程设计中,按照实验要求,基本上实现了课题的要求,运用栈来实现商品货架管理。通过这次课设发现许多的不足之处,在函数的逻辑上还有欠缺,基本函数不能灵活使用。在课设过程中,对软件编程更加熟练,扩展了知识,也将课本与实际结合,激起我对软件的兴趣,受益匪浅。
5.程序清单
#include \#include \#include \#define MAXSIZE 100 #define Esc 27
int date; /*商品结构体*/ struct Goods { int num; int date; };
/*栈结构体*/ typedef struct {
struct Goods data[MAXSIZE]; int top; }SeqStack;
/***************函数声明***************/ SeqStack *Init_SeqStack(); //置空栈 int Empty_SeqStack(SeqStack *s); //判栈空
int Push_SeqStack(SeqStack *s,struct Goods x); //入栈 int Pop_SeqStack(SeqStack *s,struct Goods *x); //出栈 int Max_date(struct Goods a[], int count); //找日期最大值 void Goods_arrange(struct Goods a[], int count);//选择排序 void Goods_print(SeqStack *s); //打印商品信息 void Goods_in(SeqStack *s); //商品上架 void Goods_out(SeqStack *s); //商品出售 void main_menu(); //主菜单 void print_menu(); //查看菜单 int main(); //主函数
/************************************************/
//置空栈
SeqStack *Init_SeqStack() {
SeqStack *s;
s=(SeqStack *)malloc(sizeof(SeqStack)); s->top=-1; return s; } //判栈空
int Empty_SeqStack(SeqStack *s) {
if(s->top==-1) return 1; else return 0; } //入栈
int Push_SeqStack(SeqStack *s,struct Goods x) {
if(s->top==MAXSIZE-1) return 0; else {
s->top++;
s->data[s->top] = x; return 1; } } //出栈
int Pop_SeqStack(SeqStack *s,struct Goods *x)
{
if (Empty_SeqStack(s)) return 0; else {
*x=s->data[s->top]; s->top--; return 1; } }
/*找日期最大值*/
int Max_date(struct Goods a[], int count) { int k=0; int i;
for(i=1; i if(a[k].date > a[i].date) k=i; } return k; } //选择排序 void Goods_arrange(struct Goods a[], int count) { int i, j; struct Goods temp; for(i=count; i>1; i--)