超市管理系统 C语言.doc

上传人:钟*** 文档编号:5396298 上传时间:2020-01-28 格式:DOC 页数:35 大小:338.50KB
返回 下载 相关 举报
超市管理系统 C语言.doc_第1页
第1页 / 共35页
超市管理系统 C语言.doc_第2页
第2页 / 共35页
超市管理系统 C语言.doc_第3页
第3页 / 共35页
点击查看更多>>
资源描述
.西安邮电大学高级语言课程设计报告题 目: 超市管理系统院系名称: 理学院 专业名称: 应用物理学班 级: 1301 学生姓名: 王松学号(8位): 07132022指导教师: 王西龙设计起止时间:2014年06月19日2014年06月27日1:程序模型2:原函数概况1:创建函数void start(); /*启动界面*/void input(); /*商品数据信息输入函数*/void change(); /*商品数据信息修改函数*/void dele(); /*给定指定商品名称,删除商品信息*/void output(); /*商品信息输出*/void search(); /*商品信息查找*/void mima();/*密码程序*/void colour();/颜色选择void huanying();2:商品信息录入input()3:商品信息的修改Change()4:商品信息的删除Dele()5:商品信息的查询Seaerch()6:系统颜色选择Colour()7:退出系统3:详细设计过程1:结构体变量的定义struct MarketGoods /*存数商品信息的结构体*/ char goods_id30; /*商品编号*/ char goods_name30; /*商品名称*/double goods_price; /*商品价格*/double goods_discount;/*商品折扣*/int goods_amount;/*商品总数目*/int goods_remain;/*商品剩余数目*/goodsCOUNT;int count=0; /*全局变量,用于保存实际上有多少个商品*/2:欢迎界面void huanying()printf(t333333333333333333333333333333n); printf(t3 欢迎使用 3n); printf(t3 3n); printf(t3 3n); printf(t3 超市管理系统 3n); printf(t3 3n); printf(t3 3n); printf(t3 444444 3n); printf(t3 3n); printf(t3 555555555 3n); printf(t3 3n);printf(t3333333333333333333333333333333n);3:密码登陆void mima()/char pass6=1,2,3,4,5,6;/*假设密码长度是6*/ char pass=123456;/*假设密码长度是6*/ char str6,ch;int i=0;int flag=0;printf( 请输入密码:); fflush(stdin);for(i=0;i6;i+) ch=getch(); /*读取字符,不显示*/stri=ch;putchar(*); for(i=0;i6;i+)if(stri!=passi) flag=1;break;if(flag)printf(n密码错误,登录失败!请重新登录n);mima();else printf(n登录成功n);getch();system(cls);start();4:系统选择界面void start() /*启动菜单*/int chi; printf( 超市商品管理系统n);printf( *n); printf( *n); printf( 1.商品信息的录入:n);printf( 2.商品信息的修改:n); printf( 3.删除某个商品信息:n); printf( 4.查找商品信息:n); printf( 5.颜色选择:n); printf( 0.退出程序n);printf( *n); printf( *n); printf( 输入你的选择: ); scanf(%d,&chi); /*根据你的选择执行相应的函数*/if(chi=1) input(); else if(chi=2) change();else if(chi=3) dele();else if(chi=4) search(); else if(chi=5) colour();else if(chi=0) printf(你已经退出超市商品管理系统!谢谢您的使用,再见n); exit(0);elseprintf( You Enter The Choice Is Not valid ! n);getch();system(cls);start();void huanying()printf(t333333333333333333333333333333n); printf(t3 欢迎使用 3n); printf(t3 3n); printf(t3 3n); printf(t3 超市管理系统 3n); printf(t3 3n); printf(t3 3n); printf(t3 444444 3n); printf(t3 3n); printf(t3 555555555 3n); printf(t3 3n);printf(t3333333333333333333333333333333n);5:商品信息的录入void input() /*数据录入*/FILE *fp;char flag20;fp=fopen(e:/student.txt,wt);doprintf(请输入你的商品信息:n); /*录入商品的信息*/ printf(商品编号:); scanf(%s,goodscount.goods_id); printf(商品名字:); scanf(%s,goodscount.goods_name); printf(商品价格:); scanf(%lf,&goodscount.goods_price); printf(商品折扣:); scanf(%lf,&goodscount.goods_discount); printf(商品总数目:); scanf(%d,&goodscount.goods_amount); printf(商品剩余数目:); scanf(%d,&goodscount.goods_remain); count+; /*存数的商品数加一*/ printf(是否继续输入数据 y是 n否 : ); /*是否还想继续输入数据*/ scanf(%s,flag); while(strcmp(flag,y)=0|strcmp(flag,Y)=0);fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output(); /*调用显示商品数据*/getch();system(cls);start();6:商品信息的修改void change() /*数据修改*/ FILE *fp;int i,m=0;char ch20,a20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)m+;fclose(fp);printf(nyou sure want change goodsInfor y/n): );/*根据商品的id来修改数据*/ scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nenter you want change goods_id:); scanf(%s,a); for(i=0;icount;i+) if(strcmp(goodsi.goods_id,a)=0) printf(nyou sure want change goods name(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nname:);scanf(%s,goodsi.goods_name); printf(nyou sure want change goods price(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nprice);scanf(%lf,&goodsi.goods_price); printf(nyou sure want goods discount(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(ndiscount); scanf(%lf,&goodsi.goods_discount); printf(nyou sure want goods amount(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(namount);scanf(%d,&goodsi.goods_amount);printf(nyou sure want goods remain(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nremain); scanf(%d,&goodsi.goods_remain); fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output();getch();system(cls);start();7:商品信息的删除void dele() /*数据删除*/FILE *fp;int i,m=0,j;char ch20,c20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)printf(%s,goodsm.goods_id);m+;fclose(fp);printf(nenter you want delete name :n); /*根据商品的名称来删除数据*/ printf(name:); scanf(%s,c); for(i=0;icount;i+) if(strcmp(c,goodsi.goods_name)=0) break; /*找到,即跳出循环*/ for(j=i;jcount-1;j+) goodsj=goodsj+1; printf(tttyou had delete %sn,c); count-;fp=fopen(e:/student.txt,wt);fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output();getch();system(cls);start();8:商品信息查询void search() /*数据查找*/FILE *fp;int i,m=0;char a20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)printf(%s,goodsm.goods_name);m+;printf(nenter you want look name:); /*根据商品的名称来查找数据*/ scanf(%s,a); for(i=0;im;i+)if(strcmp(goodsi.goods_name,a)=0) printf(%s %s %lf %lf %d %d n,goodsi.goods_id,goodsi.goods_name,goodsi.goods_price,goodsi.goods_discount,goodsi.goods_amount,goodsi.goods_remain);getch();system(cls);start();9:系统颜色选择void colour() int a; printf(nntt选择以下方案n);printf(nntt1*红底黑字n);printf(nntt2*白底黑子);printf(nntt3*黑底红字);printf(nntt4*绿底蓝字);printf(nntt5*黄底蓝字);printf(nntt6*系统默认);printf(nntttt请挑选您喜欢的颜色.);scanf(%d,&a);switch(a)case 1:system(color 40); break;case 2:system(color 70); break;case 3:system(color 04); break;case 4:system(color 21); break;case 5:system(color 65); break;case 6:system(color la); break;default:printf(nntttt输入无效);getch();colour(); start();10:商品信息输出void output() /*数据输出*/ FILE *fp; int i,m=0;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)m+; fclose(fp);printf( 编号 名称 价格 折扣 总数目 剩余数目 n);for(i=0;im;i+)printf(%s %s %lf %lf %10d %10d n,goodsi.goods_id,goodsi.goods_name,goodsi.goods_price,goodsi.goods_discount,goodsi.goods_amount,goodsi.goods_remain);getch();system(cls);start();11:退出系统 void start() /*启动菜单*/int chi; printf( 超市商品管理系统n);printf( *n); printf( *n); printf( 1.商品信息的录入:n);printf( 2.商品信息的修改:n); printf( 3.删除某个商品信息:n); printf( 4.查找商品信息:n); printf( 5.颜色选择:n); printf( 0.退出程序n);printf( *n); printf( *n); printf( 输入你的选择: ); scanf(%d,&chi); /*根据你的选择执行相应的函数*/if(chi=1) input(); else if(chi=2) change();else if(chi=3) dele();else if(chi=4) search(); else if(chi=5) colour();else if(chi=0) printf(你已经退出超市商品管理系统!谢谢您的使用,再见n); exit(0);4:调试分析调试过程中,会有很多的错误。语句和函数的运用不到位,还存在许多的小错误。5:测试结果 通过我想同学求助,向老师咨询,查找书籍,在网络上查找,最终使得程序顺利运行。1:欢迎界面2:密码输入3:系统菜单选择界面4:商品信息录入及保存5:商品信息的修改6:商品信息的删除及剩余物品记录7:物品信息的查询8:商品信息输出9:系统环境颜色的选择10:退出系统 课程设计总结上学期学习了C语言,所以对于C语言有了初步和基础的认识。这次做程序设计,许多的程序过程都是通过咨询老师,同学,查询网络,查找书籍做的。感到自己的C语言知识还是很欠缺。程序中许多都是自己设计的简单的语句,很少有精彩的部分,但是很知足,毕竟是自己第一次做,感觉挺好。但是总结下来,自己可是漏洞百出。通过一周多的实习设计,使我对于C语言有了更深刻,更多的了解,也是我认识到C语言的难度,但是,我又感觉到了这门课程的乐趣,看着自己的成果一天天出现,那种喜悦是不可言语的。过程中,我发现自己的基础知识薄弱,英语很多不认识,知识做的过程中还要上查询英语方面的知识,很是费事。还有就是有些概念很模糊,但是通过这次实习,我对于C语言有了新的认识。在这一周时间里,经过不断的与同学和老师的讨论,是我的C语言水平有了很大的提高。此次我还感觉到,C语言是一门实用性很强的课程。其实真正的程序过程就是头文件,主函数,模块函数。这些东西的组合才构成了一个完整的函数体系。虽然说只有这几项,但是就是这简单的几项,在一起通过逻辑,顺序,等关系罗列开来,构成了复杂的函数体。我就是在程序作业工程中老是在各种逻辑顺序中迷糊,所以浪费了很长时间。这次的实验设计,让我对C语言有了很大的兴趣。我相信我还会去自学的,因为我知道只是一门可以武装子的课程。相信,通过这次的学习,还有以后的学习,会是我的C语言有很大的提高。 源程序#include #include #include #include #define COUNT 30 /*声明商品的种类为30中*/#define N 30void start(); /*启动界面*/void input(); /*商品数据信息输入函数*/void change(); /*商品数据信息修改函数*/void dele(); /*给定指定商品名称,删除商品信息*/void output(); /*商品信息输出*/void search(); /*商品信息查找*/void mima();/*密码程序*/void colour();/颜色选择void huanying();void paixu();struct MarketGoods /*存数商品信息的结构体*/ char goods_id30; /*商品编号*/ char goods_name30; /*商品名称*/double goods_price; /*商品价格*/double goods_discount;/*商品折扣*/int goods_amount;/*商品总数目*/int goods_remain;/*商品剩余数目*/goodsCOUNT;int count=0; /*全局变量,用于保存实际上有多少个商品*/void main() /*主函数*/ huanying();mima();start(); void start() /*启动菜单*/int chi; printf( 超市商品管理系统n);printf( *n); printf( *n); printf( 1.商品信息录入:n);printf( 2.商品信息修改:n); printf( 3.商品信息删除:n); printf( 4.商品信息查找:n); printf( 5.系统颜色选择:n); printf( 6.商品信息输出:n); printf( 0.退出程序n);printf( *n); printf( *n); printf( 输入你的选择: ); scanf(%d,&chi); /*根据你的选择执行相应的函数*/if(chi=1) input(); else if(chi=2) change();else if(chi=3) dele();else if(chi=4) search(); else if(chi=5) colour(); else if(chi=6) output();else if(chi=0) printf(你已经退出超市商品管理系统!谢谢您的使用,再见n); exit(0);elseprintf( You Enter The Choice Is Not valid ! n);getch();system(cls);start();void huanying()printf(t333333333333333333333333333333n); printf(t3 欢迎使用 3n); printf(t3 3n); printf(t3 3n); printf(t3 超市管理系统 3n); printf(t3 3n); printf(t3 3n); printf(t3 444444 3n); printf(t3 3n); printf(t3 555555555 3n); printf(t3 3n);printf(t3333333333333333333333333333333n);void mima()/char pass6=1,2,3,4,5,6;/*假设密码长度是6*/ char pass=123456;/*假设密码长度是6*/ char str6,ch;int i=0;int flag=0;printf( 请输入密码:); fflush(stdin);for(i=0;i6;i+) ch=getch(); /*读取字符,不显示*/stri=ch;putchar(*); for(i=0;i6;i+)if(stri!=passi) flag=1;break;if(flag)printf(n密码错误,登录失败!请重新登录n);mima();else printf(n登录成功n);getch();system(cls);start();void input() /*数据录入*/FILE *fp;char flag20;fp=fopen(e:/student.txt,wt);doprintf(请输入你的商品信息:n); /*录入商品的信息*/ printf(商品编号:); scanf(%s,goodscount.goods_id); printf(商品名字:); scanf(%s,goodscount.goods_name); printf(商品价格:); scanf(%lf,&goodscount.goods_price); printf(商品折扣:); scanf(%lf,&goodscount.goods_discount); printf(商品总数目:); scanf(%d,&goodscount.goods_amount); printf(商品剩余数目:); scanf(%d,&goodscount.goods_remain); count+; /*存数的商品数加一*/ printf(是否继续输入数据 y是 n否 : ); /*是否还想继续输入数据*/ scanf(%s,flag); while(strcmp(flag,y)=0|strcmp(flag,Y)=0);fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output(); /*调用显示商品数据*/getch();system(cls);start();void paixu()FILE *fp; int m=0;int u,j,t;double dN+1;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)m+; fclose(fp); dN+1=goodscount.goods_price; for(u=1;uN;u+) for(j=u+1;j=N;j+) if(dudj)t=du;du=dj;dj=t; printf(商品信息:n); printf( 编号 名称 价格 折扣 总数目 剩余数目 n); for(u=1;u=N;u+) printf(%4d,du);void change() /*数据修改*/ FILE *fp;int i,m=0;char ch20,a20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)m+;fclose(fp);printf(nyou sure want change goodsInfor y/n): );/*根据商品的id来修改数据*/ scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nenter you want change goods_id:); scanf(%s,a); for(i=0;icount;i+) if(strcmp(goodsi.goods_id,a)=0) printf(nyou sure want change goods name(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nname:);scanf(%s,goodsi.goods_name); printf(nyou sure want change goods price(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nprice);scanf(%lf,&goodsi.goods_price); printf(nyou sure want goods discount(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(ndiscount); scanf(%lf,&goodsi.goods_discount); printf(nyou sure want goods amount(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(namount);scanf(%d,&goodsi.goods_amount);printf(nyou sure want goods remain(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nremain); scanf(%d,&goodsi.goods_remain); fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output();getch();system(cls);start();void dele() /*数据删除*/FILE *fp;int i,m=0,j;char ch20,c20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)printf(%s,goodsm.goods_id);m+;fclose(fp);printf(nenter you want delete name :n); /*根据商品的名称来删除数据*/ printf(name:); scanf(%s,c); for(i=0;icount;i+) if(strcmp(c,goodsi.goods_name)=0) break; /*找到,即跳出循环*/ for(j=i;jcount-1;j+) goodsj=goodsj+1; printf(tttyou had delete %sn,c); count-;fp=fopen(e:/student.txt,wt);fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output();getch();system(cls);start();void output() /*数据输出*/ FILE *fp; int i,m=0;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)m+; fclose(fp);printf( 编号 名称 价格 折扣 总数目 剩余数目 n);for(i=0;im;i+)printf(%s %s %lf %lf %10d %10d n,goodsi.goods_id,goodsi.goods_name,goodsi.goods_price,goodsi.goods_discount,goodsi.goods_amount,goodsi.goods_remain);getch();system(cls);start();void search() /*数据查找*/FILE *fp;int i,m=0;char a20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)printf(%s,goodsm.goods_name);m+;printf(nenter you want look name:); /*根据商品的名称来查找数据*/ scanf(%s,a); for(i=0;im;i+)if(strcmp(goodsi.goods_name,a)=0) printf(%s %s %lf %lf %d %d n,goodsi.goods_id,goodsi.goods_name,goodsi.goods_price,goodsi.goods_discount,goodsi.goods_amount,goodsi.goods_remain);getch();system(cls);start();void colour() int a; printf(nntt选择以下方案n);printf(nntt1*红底黑字n);printf(nntt2*白底黑字);printf(nntt3*黑底红字);printf(nntt4*绿底蓝字);printf(nntt5*黄底蓝字);printf(nntt6*系统默认);printf(nntttt请挑选您喜欢的颜色.);scanf(%d,&a);switch(a)case 1:system(color 40); break;case 2:system(color 70); break;case 3:system(color 04); break;case 4:system(color 21); break;case 5:system(color 65); break;case 6:system(color la); break;default:printf(nntttt输入无效);getch(
展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!