资源描述
/*-时间:2015-7-1 16:44:21吴俊龙C语言专周设计超市收银系统-*/# include # include #include int menu1(void);/主页面int menu2(void);/商品管理页面int menu3(void);/退出页面int menu4(void);/添加商品信息int menu5(void);/商品信息浏览int menu6(void);/商品信息修改int menu7(void);/商品信息查询int menu8(void);/商品信息删除int menu9(void);/结账 页面int sign(void);/欢迎页面struct imaint id; /商品编号char name20; /商品的名称char produce30; /商品的产地int number; /商品的数量int money; /商品的价格;int len = 0;struct ima thing50;struct ima * p; int menu1(void)/主页面int n;system(cls);printf(nnn);printf(tt - n);printf(tt| 欢迎使用结账管理系统 |n);printf(tt|-|n);printf(tt| |n);printf(tt| 1.商品管理 |n);printf(tt| |n);printf(tt| 2.结账模式 |n);printf(tt| |n);printf(tt| 3.退出系统 |n); printf(tt| |n);printf(tt|_|n);printf(ntt请输入您要进行的操作(1-3) bb); scanf(%d,&n); while( n != 1 & n != 2 & n != 3 )printf( 提示:nt 输入有误,请重新输入您要进行的操作(1-3):n);scanf(%d,&n); return n;int menu2(void)/商品管理页面int n;system(cls);printf(nnn);printf(tt - n);printf(tt| 商品信息管理页面 |n);printf(tt|-|n);printf(tt| |n);printf(tt| 1.新购商品入库 |n);printf(tt| 2.商品信息删除 |n);printf(tt| 3.商品信息修改 |n);printf(tt| 4.商品信息查询 |n);printf(tt| 5.商品信息浏览 |n);printf(tt| 6.返回 主菜单 |n);printf(tt| |n);printf(tt|_|n);printf(n t请输入您要进行的操作(1-6) bb); scanf(%d,&n); while( n!=1 & n!=2 & n!=3 & n!=4 & n!=5 & n!=6)printf( 提示: n输入有误,请重新输入您要进行的操作(1-6):n);scanf(%d,&n); return n;int menu9(void)/结账 页面system(cls);float tot = 0, pay = 0;if(len != 0)int i;system(cls);printf(nnn);printf(tt - n);printf(tt| 商品 结账 页面 |n);printf(tt|-|n);printf(tt编号t名称t产地t数量t单价n);printf(-n);for(i=0; ilen; i+)printf(tt %dt %st%st%dt%dtnn, thingi.id, thingi.name, thingi.produce, thingi.number, thingi.money);tot = (float)(thingi.number * thingi.money*10)/10);pay+=tot;printf(tttttttttttttttt总共消费 :%.2fnn, pay);system(pause);else printf(t亲购物车中没有商品,请先添加商品信息哟);system(pause);return 0;int menu8(void)/商品信息删除int i, j, num, e, t = len;if(len != 0)printf(t请输入您要删除的商品的编号:);scanf(%d,&num);for(i=0; ilen; i+)if(thingi.id = num)j = i;if(j != (t-1)for(e=i-1; et; e+, j+)thingj.id = thingj+1.id;strcpy(thingj.name, thingj+1.name);strcpy(thingj.produce, thingj+1.produce);thingj.number = thingj+1.number;thingj.money = thingj+1.money;t-;p+;else t-;p-;printf(提示:删除完毕!);system(pause);else printf(暂无数据,请先添加商品信息!);system(pause);return 0;int menu7(void)/商品信息查询int j, i, c, w;char name20;if(len != 0)dosystem(cls);printf(nnn);printf(tt - n);printf(tt| 商品信息查询 |n);printf(tt|-|n);printf(tt| |n);printf(tt| 按编号查询 请按 1 |n);printf(tt| 按名称查询 请按 2 |n);printf(tt| 取消 请按 0 |n);printf(tt|_|n);printf(t请输入您的选择:);scanf(%d, &c);switch(c)case 0:break;case 1:printf(t 请输入商品的编号;);scanf(%d, &w);for(i=0; ilen; i+)if(thingi.id = w)system(cls);printf(nntt- - - - - - - - - - - -n);printf(tt商品编号:%dn, thingi.id );printf(tt商品名称:%sn, thingi.name);printf(tt商品产地:%sn, thingi.produce);printf(tt商品数量:%dn, thingi.number);printf(tt商品价格:%dn, thingi.money);system(pause);j=1;if(j=0)printf(提示:nt没有该商品记录,请核对!);break;case 2:printf(t 请输入商品的姓名:);scanf(%s, name);for(i=0; ilen; i+)if(strcmp(name, thingi.name) = 0)system(cls);printf(nntt- - - - - - - - - - - -n);printf(tt商品编号:%dn, thingi.id );printf(tt商品名称:%sn, thingi.name);printf(tt商品产地:%sn, thingi.produce);printf(tt商品数量:%dn, thingi.number);printf(tt商品价格:%dn, thingi.money);j=1;system(pause);if(j=0)printf(提示:没有该商品记录,请核对!);break;default:printf(n 提示:您的输入有误,请重新输入!);break;/属于switchwhile(c!= 0);/属于do/属于ifelse printf(暂无数据,请先添加商品信息!);system(pause);return 0;int menu6(void)/商品信息修改int num;int i, c;if(len != 0)system(cls);printf(t 请输入您要修改的商品的编号:);scanf(%d, &num);for(i=0; ilen; i+)if( thingi.id = num )break;dosystem(cls);printf(nnn);printf( 请选择您要修改的商品的信息内容:n);printf(tt - n);printf(tt| 商品管理系统 |n);printf(tt|-|n);printf(tt| |n);printf(tt| 名称 请按 1 |n);printf(tt| 数量 请按 2 |n);printf(tt| 产地 请按 3 |n);printf(tt| 价格 请按 4 |n);printf(tt| 取消 请按 0 |n);printf(tt|_|n);printf(t 请输入您的选择:);scanf(%d, &c);switch(c)case 0:break;case 1:printf(请输入新的商品名称:);scanf(%s,thingi.name);break;case 2:printf(请输入新的商品数量:);scanf(%d,&thingi.number);break;case 3:printf(请输入新的商品产地:);scanf(%s,thingi.produce);break;case 4:printf(请输入新的商品价格:);scanf(%d,&thingi.money);break;default:printf(n 提示:您的输入有误,请重新输入!);break;if(c=1 | c=2 | c=3 | c=4)printf(nt 修改成功 );system(pause);while(c != 0);printf(nt正在保存数据中.);for(i=0;iid = i;printf(tt商品名称:);scanf(%s, p-name);printf(tt商品产地:);scanf(%s, p-produce);printf(tt商品数量:);scanf(%d, &p-number);printf(tt商品价格:);scanf(%d, &p-money);t-;p+;printf(tt- - - - - - - - - - - -n);while(t != 0);printf(nt已经添加成功,即将返回上一级页面 .);for(i=0;i10;i+) printf( .);Sleep(500);return 0;int menu5(void)/查看已经添加的商品if(len != 0)int i;system(cls);printf(nnn);printf(tt - n);printf(tt| 查看商品信息页面 |n);printf(tt|-|n);if(len != 0)for(i=0; i);for(i=0; i);Sleep(500);return 0;int main(void)/主函数sign();/版权system(color f0);system(cls);back:switch(menu1()case 1: /主函数 商品管理页面come:switch(menu2()case 1:/添加商品信息(完成)menu4();goto come;break;case 2:/商品信息删除(完成)menu8();goto come;break;case 3:/商品信息修改(完成)menu6();goto come;break;case 4:/商品信息查询(完成)menu7();goto come;break;case 5:/商品信息浏览(完成)menu5();goto come;break;case 6:/返回主菜单(完成)goto back;break;break;case 2: /主页面结账模式menu9();goto back;break;case 3:/ 主页面 退出menu3();break;Sleep(3000);return 0;
展开阅读全文