超市管理系统C语言_第1页
超市管理系统C语言_第2页
超市管理系统C语言_第3页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、西安邮电大学高级语言课程设计报告题 目:超市管理系统院系名称:理学院专业名称:应用物理学班 级:1301学生姓名:王松学号(8 位):07132022指导教师:王西龙设计起止时间:2014年06月19日2014年06月27日 1:程序模型 2:原函数概况1:创建函数void start(); /*启动界面*/void in put(); /*商品数据信息输入函数*/void cha nge(); /*商品数据信息修改函数*/void dele(); /*给定指定商品名称,删除商品信息*/void output(); /*商品信息输出*/void search(); /*商品信息查找*/void

2、 mima();/*密码程序 */void colour();品信息的录入:n");printf("2.商品信息的修改:n");printf("3.删除某个商品信息:n");printf("4.查找商品信息 :n");printf("5.颜色选择 :n");printf("0.退出程序 n");printf("*n");printf("*n");printf("输入你的选择 : ");scanf("%d",

3、&chi); /* 根据你的选择执行相应的函数 */ if(chi=1) input();elseif(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("c

4、ls");start();void huanying() printf("t333333333333333333333333333333n");printf("t3欢迎使用3n");printf("t33n");printf("t33n");printf("t3超市管理系统3n");printf("t33n");printf("t33n");printf("t3444444 3n");printf("t33n&quo

5、t;);printf("t3555555555 3n");printf("t33n");n");5:商品信息的录入void input() /* 数据录入 */FILE *fp;char flag20;fp=fopen("e:/","wt");doprintf(" 请输入你的商品信息 :n"); /* 录入商品的信息 */ printf(" 商品编号 :");scanf("%s",goodscount.goods_id);printf("

6、; 商品名字 :"); scanf("%s",goodscount.goods_name);printf(" 商品价格 :"); scanf("%lf",&goodscount.goods_price);printf(" 商品折扣 :"); scanf("%lf",&goodscount.goods_discount);printf(" 商品总数目 :"); scanf("%d",&goodscount.goods_amo

7、unt);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 MarketGoo

8、ds),count,fp);fclose(fp);output(); /* 调用显示商品数据 */ getch();system("cls");start();6:商品信息的修改void change() /* 数据修改 */FILE *fp;int i,m=0;char ch20,a20;fp=fopen("e:/","rt"); while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)m+;fclose(fp);printf("nyou sure wa

9、nt 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;i<count;i+) if(strcmp(goodsi.goods_id,a)=0)printf("nyou sure want cha

10、nge 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|st

11、rcmp(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",&

12、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(

13、"%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() /*数据删除 */FI

14、LE *fp;int i,m=0,j;char ch20,c20;fp=fopen("e:/","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("

15、;%s",c);for(i=0;i<count;i+) if(strcmp(c,goodsi.goods_name)=0) break; /* 找到, 即跳出循环 */ for(j=i;j<count-1;j+) goodsj=goodsj+1;printf("tttyou had delete %sn",c);count-;fp=fopen("e:/","wt");fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output()

16、;getch();system("cls");start();8:商品信息查询void search() /* 数据查找 */FILE *fp; int i,m=0;char a20;fp=fopen("e:/","rt");while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL) printf("%s",goodsm.goods_name);m+;printf("nenter you want look name:"); /

17、*根据商品的名称来查找数据 */scanf("%s",a);for(i=0;i<m;i+)%d if(strcmp(goodsi.goods_name,a)=0) printf("%s %s %lf %lf %d n",goodsi.goods_id,goodsi.goods_name,goodsi.goods_price,goodsi.good s_discount,goodsi.goods_amount,goodsi.goods_remain);getch();system("cls");start();9:系统颜色选择 v

18、oid colour()int a;printf("nntt 选择以下方案 n");printf("nntt1*printf("nntt2* printf("nntt3* printf("nntt4* printf("nntt5* printf("nntt6* printf("nntttt红底黑字 n");白底黑子 ");黑底红字 ");绿底蓝字 ");黄底蓝字 ");系统默认 ");请挑选您喜欢的颜色 <1-6>");sc

19、anf("%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; defau

20、lt:printf("nntttt输入无效 ");getch();colour();getch(); system("cls"); start(); 11:退出系统 void start()int chi;printf("printf("printf("printf(" printf(" printf(" printf(" printf(" printf(" printf(" printf("printf("/*启动菜单 */1.2.3

21、.4.5.0.scanf("%d",&chi); /* if(chi=1) input();start();10:商品信息输出void output() /*数据输出 */ FILE *fp;int i,m=0;fp=fopen("e:/","rt");while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL) m+; fclose(fp);printf(" 编号 名称 价格 折扣 总数目 剩余数目 n"); for(i=0;i<m;

22、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);超市商品管理系统 n");*n");*n"); 商品信息的录入 :n"); 商品信息的修改 :n"); 删除某个商品信息 :n"); 查找商品信息 :n"); 颜色选择 :n"); 退出

23、程序 n");*n"); *n");输入你的选择 : ");根据你的选择执行相应的函数 */elseif(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:测试结果 通过我想同学求助,向老师咨询,查找书籍,

24、在网络上查找,最终使得程序顺利运 行。1:欢迎界面2:密码输入3:系统菜单选择界面4:商品信息录入及保存5:商品信息的修改6:商品信息的删除及剩余物品记录7:物品信息的查询8:商品信息输出9:系统环境颜色的选择10:退出系统课程设计总结上学期学习了 C语言,所以对于C语言有了初步和基础的认识。这次做程序设计,许多的程序过程都是通过咨询老师,同学,查询网络,查找书籍做的。感到自己的C语言知识还是很欠缺。程序中许多都是自己设计的简单 的语句, 很少有精彩的部分, 但是很知足, 毕竟是自己第一次做, 感觉挺好 但是总结下来,自己可是漏洞百出。通过一周多的实习设计,使我对于 C语言有了更深刻,更多的了

25、解,也 是我认识到C语言的难度,但是,我又感觉到了这门课程的乐趣,看着自己的成果一天天出现,那种喜悦是不可言语的。过程中,我发现自己的基础知 识薄弱,英语很多不认识,知识做的过程中还要上查询英语方面的知识,很 是费事。还有就是有些概念很模糊,但是通过这次实习,我对于C语言有了新的认识。在这一周时间里,经过不断的与同学和老师的讨论,是我的C语言水平有了很大的提高。此次我还感觉到,C语言是一门实用性很强的课程。其实真正的程序过程就是头文件,主函数,模块函数。这些东西的组合才构成了一个完整的函 数体系。虽然说只有这几项,但是就是这简单的几项,在一起通过逻辑,顺 序,等关系罗列开来,构成了复杂的函数体

26、。我就是在程序作业工程中老是 在各种逻辑顺序中迷糊,所以浪费了很长时间。这次的实验设计,让我对C语言有了很大的兴趣。我相信我还会去自学 的,因为我知道只是一门可以武装子的课程。相信,通过这次的学习,还有 以后的学习,会是我的C语言有很大的提高。源程序#include <>#include <>#include <>#include <>#define COUNT 30 /* 声明商品的种类为 30 中*/#define N 30void start(); /*启动界面 */void input(); /*商品数据信息输入函数 */void cha

27、nge(); /* 商品数据信息修改函数 */void dele(); /* 给定指定商品名称 , 删除商品信息 */void output(); /*商品信息输出 */void search(); /*商品信息查找 */void mima();/*密码程序 */void colour();品信息录入 :n");printf("2.商品信息修改:n");printf("3.商品信息删除:n");printf("4.商品信息查找:n");printf("5.系统颜色选择:n");printf("6

28、.商品信息输出 :nprintf("0.退出程序 n");printf("*n");printf("*n");printf("输入你的选择 : ");scanf("%d",&chi); /*根据你的选择执行相应的函数 */if(chi=1) input();elseif(chi=2) change();else if(chi=3) dele();else if(chi=4) search();else if(chi=5) colour();else if(chi=6) output();

29、else if(chi=0)printf(" 你已经退出超市商品管理系统 ! 谢谢您的使用,再见 n");exit(0);elseprintf(" You Enter The Choice Is Not valid ! n");getch();system("cls");start();void huanying()333333n");printf("t3欢迎使用3n");printf("t33n");printf("t33n");printf("t3 超

30、 市 管 理 系 统3n");printf("t33n");printf("t33n");printf("t3 4444443n");printf("t33n");printf("t3 5555555553n");printf("t33n");3333333n");void mima()oods_id);printf(" 商品名字 :");scanf("%s",goodscount.goods_name);print

31、f(" 商品价格 :"); scanf("%lf",&goodscount.goods_price); printf(" 商品折扣 :"); scanf("%lf",&goodscount.goods_discount);printf(" 商品总数目 :"); scanf("%d",&goodscount.goods_amount); printf(" 商品剩余数目 :"); scanf("%d",&go

32、odscount.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();sys

33、tem("cls");start();void paixu()FILE *fp;int m=0;int u,j,t;double dN+1;fp=fopen("e:/","rt");while(fread(&goodsm,sizeof(structMarketGoods),1,fp)!=NULL)m+;fclose(fp);dN+1=goodscount.goods_price;for(u=1;u<N;u+)for(j=u+1;j<=N;j+)if(du<dj) t=du;du=dj;dj=t;printf(

34、"商品信息 :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:/","rt");while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)m+;fclose(fp);剩余数/* 根printf(&qu

35、ot;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;i<count;i+) if(strcmp(goodsi.goods_id,a)=0)printf("nyou su

36、re 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&qu

37、ot;)=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",&

38、amp;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(

39、"%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

40、 i,m=0,j;char ch20,c20;fp=fopen("e:/","rt");while(fread(&goodsm,sizeof(structMarketGoods),1,fp)!=NULL)printf("%s",goodsm.goods_id);m+; fclose(fp);根据商品的名printf("nenter you want delete name: n"); /*称来删除数据 */printf("name : ");scanf("%s",c)

41、;for(i=0;i<count;i+)if(strcmp(c,goodsi.goods_name)=0) break; /* 找到, 即跳出循环 */for(j=i;j<count-1;j+) goodsj=goodsj+1;printf("tttyou had delete %sn",c);count-;fp=fopen("e:/","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:/","rt");while(fread(&goodsm,sizeof(structMarketGoods),1,fp)!=NULL)m+;fclose(fp);剩余数printf(" 编号 名称 价格 折扣 总数目目 n");for(i=0;i<m;i+)pr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论