超市管理系统-C语言
超市食品管理系统c语言实验报告

超市食品管理系统c语言实验报告摘要本实验设计和实现了一个基于c语言的超市食品管理系统。
通过该系统,用户可以方便地管理超市中的食品信息,包括货物进货、商品管理、库存统计、价格计算以及销售管理等功能。
通过对系统的设计和实现过程的详细分析,本报告介绍了系统的功能需求、设计思路、算法实现、界面展示和测试结果等内容。
从整体上来说,该系统实现了对超市食品的全方面管理,提高了工作效率,减少了人力成本。
1. 引言随着社会的发展,超市业已成为人们购买日常用品的主要场所之一。
在超市中,食品是其中的主要组成部分,对于超市来说,合理管理食品的进货、售卖和库存等是非常重要的。
因此,本实验设计和实现了一个基于c语言的超市食品管理系统,旨在提高超市工作效率,减少人力成本,方便管理。
2. 系统功能需求为了满足超市食品管理的需求,本系统应具备以下功能: 1. 货物进货管理:超市管理员可以通过系统进行食品的进货管理,包括进货数量、进货价格、进货时间等信息的记录和管理。
2. 商品管理:超市管理员可以通过系统进行商品的管理,包括商品名称、商品分类、商品价格等信息的维护和更新。
3. 库存统计:系统可以自动统计和更新食品的库存信息,方便管理员进行库存的掌控。
4. 价格计算:系统可以根据商品的数量和单价进行价格计算,方便管理员和顾客进行价格核算。
5. 销售管理:系统可以记录和管理超市的销售信息,包括销售数量、销售额等信息的统计和查询。
3. 系统设计思路本系统的设计思路主要包括数据结构设计、算法设计和界面设计三个方面。
3.1 数据结构设计为了方便对超市食品的管理和操作,本系统采用了以下数据结构: - 商品信息结构体:包括商品名称、商品分类、商品价格等字段,用于存储每个商品的信息。
-进货信息结构体:包括进货数量、进货价格、进货时间等字段,用于存储每次进货的信息。
- 销售信息结构体:包括销售数量、销售额等字段,用于存储每次销售的信息。
超市商品管理系统C语言源代码

超市商品管理系统C语言源代码SANY GROUP system office room 【SANYUA16H-SANYHUASANYUA8Q8-#include <stdio.h>#include <math.h>#include <string.h>#include<conio.h>#include<stdio.h>#include<string.h>#define MAX 20#define PRINT1 printf("---------------------------------------------------------\n")#define PRINT2 printf("商品号--商品名称--商品种类--销售价格--生产日期(年-月-日)--保质期\n")#define PRINT3 printf("M%8s%8s崓----M\n",goods[i].num,goods[i].name,goods[i].kind,goods[i].out_price,goods[i ].pro_time.year,goods[i].pro_time.month,goods[i].pro_time.day,goods[i].s ave_day)int sum;struct date{int year;int month;int day;};struct goods_type /*定义结构体*/{int num;char name[10];char kind[10];int amount;int in_price;int out_price;struct date pro_time;int save_day;int profit;}goods[MAX];Save_Message(int sum); /*函数声明*/void Inquire_message(void);void Inquire_goodskind(void);void Inquire_goodsname(void);int Read_Message(void);void Renew_Messahe(void);void Revise_Message(void);void Delete_Message(void);void Insert_Message();void Show_Message(void);int Input_Message(void);void Count_Message();long Count_Profit();long Count_Amount();void Sort_amount(void);void Sort_Message(void);void Sort_Message(void){int choice;do{clrscr();printf("\n\n\n *******商品信息排行********\n\n");printf(" 1:按库存量排行\n\n");printf(" 0:返回主菜单\n\n");printf(" 请选择(0-1): ");scanf("%d",&choice);switch(choice){case 1:Sort_amount();break;case 0:break;}}while(choice!=0);}void Sort_amount(void) /*库存量排序*/{struct goods_type *p,*q[MAX];int i,j,k;clrscr();printf(" 库存排行");PRINT1;printf("\n\n排名商品号商品名称商品类别库存量\n\n"); p=goods;for(i=0;i<sum;i )q[i]=p ;for(i=0;i<sum;i ){k=i;for(j=i 1;j<sum;j )if(q[k]->amount<q[j]->amount)k=j;if(k!=i){p=q[i];q[i]=q[k];q[k]=p;}}for(i=0;i<sum;i ){printf(" %d ",i 1);printf(" %d ",q[i]->num);printf(" %s ",q[i]->name);printf(" %s ",q[i]->kind);printf(" %d \n ",q[i]->amount);}bioskey(0);}long Count_Amount() /*统计库存量*/ {int i,j=0,choice,count_num,Amount;char inquire_name[10];clrscr();printf("\n 请输入想要统计的商品号: "); scanf("%d",&count_num);for(i=0;i<sum;i )if(goods[i].num==count_num){Amount=goods[i].amount;printf("-------------------------"); printf(" 商品号库存量");printf("\n崓",goods[i].num,Amount); }elsej ;if(j==sum)printf("该商品信息不存在!!!");bioskey(0);}long Count_Profit() /*统计利润模块*/{int i,choice,j=0,count_num,profit;clrscr();printf("\n 请输入想要统计的商品号: ");scanf("%d",&count_num);for(i=0;i<sum;i )if(goods[i].num==count_num){profit=goods[i].out_price-goods[i].in_price;printf("\n 商品利润");printf("\n -------------------------------");printf("\n 商品号利润");printf("\n 崓\n",&goods[i].num,&profit);}elsej ;if(j==sum)printf("\n 该商品不存在!!!");printf("\n 按任意键返回主菜单!!");bioskey(0);}void Count_Message(void) /*统计模块*/{int choice;do{clrscr();printf("**************统计商品信息*************\n\n\n");printf("******* 1:统计库存量 ************\n\n\n"); printf("******* 2:统计利润 ************\n\n\n");printf("******* 0:返回主菜单 ************\n\n\n");printf("******* 请选择(0-2): ************\n\n\n");scanf("%d",&choice);switch(choice){case 1:Count_Amount();break;case 2:Count_Profit();break;case 0:break;}}while(choice!=0);}int Input_Message(void) /*输入模块*/{int i=0,s=MAX;char bd;clrscr();printf("开始输入商品信息.\n");printf("\n\n 商品信息:(最多 %d) \n",s);printf(" ===============================\n");do{printf("\n 第 %d 商品",i 1);printf("\n 商品号: ");scanf("%d",&goods[i].num);if(goods[i].num==0) break;printf("\n 商品名称: ");scanf ("%s",goods[i].name);printf("\n 商品种类: ");scanf ("%s",goods[i].kind);printf("\n 商品库存量: ");scanf ("%d",&goods[i].amount);printf("\n 进货价格: ");scanf ("%d",&goods[i].in_price);printf("\n 销售价格: ");scanf ("%d",&goods[i].out_price);printf("\n 生产日期(yyyy-mm-dd): ");scanf ("%d-%d-%d",&goods[i].pro_time.year,&goods[i].pro_time.month,&goods[i].pro_time. day);printf("\n 保质期: ");scanf ("%d",&goods[i].save_day);printf("继续输入信息,y or n ??");fflush(stdin);scanf("%c",&bd);if(bd=='y')i ;elsebreak;}while(i<MAX);printf("\n--%d 所有商品录入完毕!--\n\n\n",i 1);getch();printf(" 按任意键返回主菜单.");sum=i;printf("输入回车返回主菜单!!!");bioskey(0);}void Show_Message(void) /*显示输出模块*/{int i=0,j=0,count,page=7;clrscr();printf("\n\n --商品信息-- 在第 %d 页\n\n",page);PRINT2;PRINT1;do{if(goods[i].num!=0){j ;if(j%page!=0){PRINT3;PRINT1;}else{PRINT3;PRINT1;if(goods[i 1].num!=0){printf("按任意键继续!");bioskey(0);clrscr();printf("\n\n --------商品信息--------在第 %d 页\n\n", page);PRINT2;PRINT1;}}}i ;}while(goods[i].num!=0);printf("按任意键返回主菜单!!!!!");bioskey(0);}void Insert_Message(void)/*添加商品信息模块*/{int i=sum,j,flag=0;char choice;clrscr();printf("\n\n 添加一种新商品\n\n ");printf("\n-------------------------------------------------\n");do{goods[i].num= sum;printf("\n 新商品号:%d",goods[i].num);printf("\n 新商品名: ");scanf("%s",goods[i].name);printf("\n 新商品种类: ");scanf("%s",goods[i].kind);printf("\n 新商品数量: ");scanf("%d",&goods[i].amount);printf("\n 进价: ");scanf("%d",&goods[i].in_price);printf("\n 售价: ");scanf("%d",&goods[i].out_price);printf("\n 生产日期(yyyy-mm-dd): ");scanf("%d-%d-%d",&goods[i].pro_time.year,&goods[i].pro_time.month,&goods[i].pro_time. day);printf("\n 保质期: ");scanf("%d",&goods[i].save_day);i ;printf("\n\n 想继续添加商品吗?(Y/N)");fflush(stdin);choice=getch();if(choice=='y'||choice=='Y'){printf("继续");flag=1;}elseflag=0;}while(flag==1);printf("\n\n\n 按任意键返回主菜单.........");bioskey(0);}void Delete_Message(void)/*删除商品信息模块*/ {int i,j,numberkey,flag=0;char choice;printf("开始删除......\n\n");do{clrscr();printf("请输入你要删除的商品号: \n");scanf("%d",&numberkey);for(i=0;i<sum;i ){if(goods[i].num==numberkey){for(j=i;j<sum;j )goods[j]=goods[j 1];sum--;flag=1;printf("删除成功!!\n\n\n");break;}}if(flag==0){printf("不存在该商品信息!!!"); bioskey(0);}printf("\n\n是否继续输入(y/n)?\n");getchar();scanf("%c",&choice);}while(choice=='y'||choice=='Y');printf("\n按任意键返回");bioskey(0);}void Revise_Message(void)/*修改商品信息模块*/ {int i,j,flag,choice,revise_num;char ch;do{clrscr();printf("\n\n 开始修改...");printf("\n\n 请输入你想输入的商品号:\n");scanf("%d",&revise_num);for(i=0;i<sum;i ){if(goods[i].num==revise_num){printf("确定修改此商品信息吗?(y/n)");PRINT1;PRINT2;PRINT3;getchar();ch=getchar();if(ch='y'){printf("\n\n\n修改商品信息的哪一项?");printf("\n\n 1:商品名称");printf("\n\n 2:商品类型");printf("\n\n 3:销售价格");printf("\n\n 4:生产日期");printf("\n\n 5:保质期");printf("\n\n 请选择(0-5)\n");scanf("\n %d",&choice);switch(choice){case 1:printf("请输入修改后的商品名\n");scanf("%s",&goods[i].name);break;case 2:printf("请输入修改后的商品类型\n");scanf("%s",&goods[i].kind);break;case 3:printf("请输入修改后的商品销售价格\n"); scanf("%d",&goods[i].out_price);break; case 4:printf("请输入修改后的商品生产日期\n"); scanf("%d-%d-%d",&goods[i].pro_time.year,&goods[i].pro_time.month,&goods[i].pro_time. day);break;case 5:printf("请输入修改后的商品保质期\n");scanf("%d",&goods[i].save_day);break;case 0:break;}printf("修改商品信息:\n");PRINT2;PRINT3;}elsebreak;}elsej ;if(j==sum)printf("不存在该商品信息..");}printf("\n\n 继续修改商品信息吗(y/n)?");getchar();ch=getchar();if(ch=='y'){printf("继续.\n");flag=1;}elseflag=0;}while(flag==1);printf("修改完成!!\n\n");getch();}void Renew_Message(void) /*更新商品信息模块*/{int choice;do{clrscr();printf("\n\n*********更新商品信息*********"); printf("\n\n 1:添加商品信息.\n\n");printf("\n\n 2:删除商品信息.\n\n");printf("\n\n 3:修改商品信息.\n\n");printf("\n\n 0:返回上一级.\n\n");printf("\n\n 请选择(0-3): ");scanf("%d",&choice);switch(choice)case 1:Insert_Message();break;case 2:Delete_Message();break;case 3:Revise_Message();break;case 0:break;}}while(choice!=0);}int Read_Message(void) /*读取信息模块*/{FILE *fp;int i=0;if((fp=fopen("999.txt","rb"))==NULL){printf("\n\t 现在还没有保存全部信息,按回车键回到主菜单输入商品信息!!");printf("\n\t 按任意键返回!!!!\n");getch();return;}while(feof(fp)!=1){fread(&goods[i],sizeof(struct goods_type),1,fp);if(goods[i].num==0)break;elsei ;}fclose(fp);return(i);}void Inquire_goodsname(void)/*按商品名称查询*/{int i,j,choice;char namekey[10];j=0;printf("开始查询...");printf("请输入你要查询的商品号:\n");scanf("%s",namekey);for(i=0;i<sum;i )if(strcmp(goods[i].name,namekey)==0&&goods[i].num!=0)printf(" ---商品信息----");PRINT1;PRINT2;PRINT3;}elsej ;if(j==sum)printf("该商品不存在!");printf("按任意键返回主菜单.");getch();}void Inquire_goodskind(void)/*按商品类型查询*/{int i,j,choice;char kindkey[10];j=0;printf("开始查询...");printf("请输入你要查询的商品种类:\n");scanf("%s",kindkey);for(i=0;i<sum;i )if(strcmp(goods[i].kind,kindkey)==0&&goods[i].num!=0) {printf(" ---商品信息----");PRINT1;PRINT2;PRINT3;}elsej ;if(j==sum)printf("该商品不存在!");printf("按任意键返回主菜单.");getch();}void Inquire_Message(void) /*查询模块*/{int choice;do{printf("\n *****查询商品信息 ***** \n");printf("\n *****1:按商品名称.***** \n");printf("\n *****2:按商品种类.***** \n");printf("\n *****0:返回上一级.***** \n");printf("\n 请选择(0-2): ***** \n");scanf("%d",&choice);switch(choice){case 1:Inquire_goodsname();break;case 2:Inquire_goodskind();break;case 0:break;}}while(choice!=0);}Save_Message(int sum) /*保存模块*/{FILE *fp;int i;if((fp=fopen("999.txt","wb"))==NULL){printf("\n\n不能打开文件!\n\n");exit();}for(i=0;i<=sum;i )if(fwrite(&goods[i],sizeof(struct goods_type),1,fp)!=1) printf("写文件出错!");fclose(fp);}void main(void) /*主函数*/{int choice;clrscr();sum=Read_Message();bioskey(0);do{clrscr();printf("***************************************************\n");printf(" ************ 超市商品管理系统**************\n");printf(" ************\n");printf(" ************\n");printf(" ************\n");printf(" ****** 欢迎登陆******\n");printf(" ************\n");printf(" ************\n");printf(" ************\n");printf("***************************************************\n");printf("***************************************************\n");getchar ();clrscr();printf(" ***************超市商品管理系统***********\n\n"); printf(" ***** 1:输入商品信息 *****\n\n"); printf(" ***** 2:输出商品信息 *****\n\n"); printf(" ***** 3:更新商品信息 *****\n\n"); printf(" ***** 4:查询商品信息 *****\n\n"); printf(" ***** 5:统计商品信息 *****\n\n"); printf(" ***** 6:商品信息排序 *****\n\n"); printf(" ***** 0:退出系统 *****\n\n"); printf(" ***** 请选择(0-6): *****\n"); scanf("%d",&choice);switch(choice){case 1:Input_Message();break;case 2:Show_Message();break;case 3:Renew_Message();break;case 4:Inquire_Message();break;case 5:Count_Message();break;case 6:Sort_Message();break;case 0:break;}}while(choice!=0);Save_Message(sum);printf("\n-信息已经保存!-(file name:999.txt)\n");。
超市管理系统C语言

超市管理系统C语言 Coca-cola standardization office【ZZ5AB-ZZSYT-ZZ2C-ZZ682T-ZZT18】西安邮电大学高级语言课程设计报告题目:超市管理系统院系名称:理学院专业名称:应用物理学班级: 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();品信息的录入:\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();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);}else{printf(" You Enter The Choice Is Not valid ! \n");getch();system("cls");start();}}void huanying(){printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\ 3\3\3\3\n");printf("\t\3 欢迎使用\3\n");printf("\t\3\3\n");printf("\t\3\3\n");printf("\t\3 超市管理系统\3\n");printf("\t\3\3\n");printf("\t\3\3\n");printf("\t\3 \4\4\4\4\4\4 \3\n"); printf("\t\3\3\n");printf("\t\3 \5\5\5\5\5\5\5\5\5 \3\n"); printf("\t\3\3\n");printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\ 3\3\3\3\3\n");}5:商品信息的录入void input() /*数据录入*/{FILE *fp;char flag[20];fp=fopen("e:/","wt");do{printf("请输入你的商品信息:\n"); /*录入商品的信息*/printf("商品编号:");scanf("%s",goods[count].goods_id);printf("商品名字:");scanf("%s",goods[count].goods_name);printf("商品价格:");scanf("%lf",&goods[count].goods_price);printf("商品折扣:");scanf("%lf",&goods[count].goods_discount);printf("商品总数目:");scanf("%d",&goods[count].goods_amount);printf("商品剩余数目:");scanf("%d",&goods[count].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 ch[20],a[20];fp=fopen("e:/","rt");while(fread(&goods[m],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;i<count;i++){if(strcmp(goods[i].goods_id,a)==0){printf("\nyou sure want change goodsname(y/n): ");scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0){printf("\nname:");scanf("%s",goods[i].goods_name);}printf("\nyou sure want change goodsprice(y/n): ");scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0){printf("\nprice");scanf("%lf",&goods[i].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",&goods[i].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",&goods[i].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",&goods[i].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 ch[20],c[20];fp=fopen("e:/","rt");while(fread(&goods[m],sizeof(struct MarketGoods),1,fp)!=NULL){printf("%s",goods[m].goods_id);m++;}fclose(fp);printf("\nenter you want delete name :\n"); /*根据商品的名称来删除数据*/printf("name:");scanf("%s",c);for(i=0;i<count;i++){if(strcmp(c,goods[i].goods_name)==0)break; /*找到,即跳出循环*/for(j=i;j<count-1;j++)goods[j]=goods[j+1];}printf("\t\t\tyou had delete %s\n",c);count--;fp=fopen("e:/","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 a[20];fp=fopen("e:/","rt");while(fread(&goods[m],sizeof(struct MarketGoods),1,fp)!=NULL){printf("%s",goods[m].goods_name);m++;}printf("\nenter you want look name:"); /*根据商品的名称来查找数据*/scanf("%s",a);for(i=0;i<m;i++){if(strcmp(goods[i].goods_name,a)==0)printf("%s %s %lf %lf %d %d\n",goods[i].goods_id,goods[i].goods_name,goods[i].goods_price,goods[ i].goods_discount,goods[i].goods_amount,goods[i].goods_remain);}getch();system("cls");start();}9:系统颜色选择void colour(){int a;printf("\n\n\t\t选择以下方案\n");printf("\n\n\t\t1**********红底黑字\n");printf("\n\n\t\t2**********白底黑子");printf("\n\n\t\t3**********黑底红字");printf("\n\n\t\t4**********绿底蓝字");printf("\n\n\t\t5**********黄底蓝字");printf("\n\n\t\t6**********系统默认");printf("\n\n\t\t\t\t请挑选您喜欢的颜色<1-6>....");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("\n\n\t\t\t\t输入无效");{getch();colour();}}start();}10:商品信息输出void output() /*数据输出*/{ FILE *fp;int i,m=0;fp=fopen("e:/","rt");while(fread(&goods[m],sizeof(struct MarketGoods),1,fp)!=NULL) {m++;}fclose(fp);printf(" 编号名称价格折扣总数目剩余数目\n");for(i=0;i<m;i++){printf("%s %s %lf %lf %10d %10d \n",goods[i].goods_id,goods[i].goods_name,goods[i].goods_price,goods[i].goods_discount,goods[i].goods_amount,goods[i].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();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:调试分析调试过程中,会有很多的错误。
C语言课程设计-超市管理系统

3.设计结果与分析
在VC 6.0环境中输入源程序,在没有提示错误的情况下编译,生成.exe可执行文件。
①运行程序,会看到如图6所示界面。
运行主函数时,首先调用函数main
图6 程序主界面
这个界面是运行函数后首先出现的界面,运行函数时,该函数是一个菜单函数,用switch 语句来实现各功能模块的转移,出来该页面后用户可根据提示输入信息,从而实现各种目的。
②键盘输入1,进入商品详细目录用以显示全部商品详细信息
图7 显示信息界面
该页面用printf输出,在利用指针读出链表中数据并利用合理计算计算出净利润等数据,再用while语句进行循环输出部数据
图8 买卖信息界面
用scanf输入数据,用if语句和while语句来实现循环每一次修改的数据④输入3按回车会进入商品登陆页面,此页面用来登陆商品。
如图9所示
图9 登录信息界面
将数据登陆入链表个变量中
图10修改信息界面
6输入5按回车进入商品删除模块如图11所示
使用printf()函数和scanf( )函数,并且利用指针从而实现各种功能。
其中用到了while 循环语句,实现对链表中个数据的重写功能。
运行完后退出该函数
图11删除信息界面。
超市管理系统、C语言课程设计

C语言程序设计超市管理系统目录第一章课程设计目的要求设计目的 (3)设计要求 (3)设计思路 (3)第二章课程设计任务内容课程设计题目 (3)课程设计任务 (4)设计内容........................... (4)各组员任务........................... (4)第三章详尽设计说明系统模块图.................................... (4)主要函数定义..................................... (5)....................... (5)构造体的成立和文件的使用 (8)构造体的成立........................... (8)第四章课程设计心得与领会 (10)3.附录·程序源代码参照文件第一章课程设计目的要求设计“商场管理系统”的主要目的是锻炼学生综合运用所学的C语言程序设计知识的能力,独自利用C语言知识编写承训解决实质问题的能力,培育同学谨慎的工作态度和优秀的程序设计习惯,让同学们认识到一定重视实践环节,多读程序,多编写程序,多上机实践。
进一步培育构造化程序设计的思想,加深对高级语言因素和控制构造的理解。
经过课程设计的训练,学生能够认识程序设计的基本开发过程,掌握编写、调试和测试C语言程序的基本过程,掌握程序设计的技巧的大概流程。
本次程序设计主要重视于知识的运用,把平常学到的运用到实践中去。
设计目标:熟习c语言的编译连结和运转过程。
掌握c语言的数据种类,熟习整型、实型、字符型变量的定义方式及怎样给它们赋值。
掌握if语句及switch语句的运用方法及嵌套应用方法。
掌握实现循环构造的三种语句while、do-while.、for的使用。
掌握函数的定义方法和调用方法。
能够采纳模块化思想调试程序。
指针和文件的使用,构造体的使用设计要求:源程序要有适合的说明,使程序简单阅读。
c语言课程设计超市管理系统

c语言课程设计超市管理系统一、教学目标本节课的教学目标是使学生掌握C语言编程基础,能够运用C语言实现简单的超市管理系统。
具体目标如下:1.知识目标:–掌握C语言的基本语法和数据类型。
–了解函数的定义和调用。
–掌握数组的声明和使用。
–理解指针的概念和应用。
2.技能目标:–能够使用C语言编写简单的程序。
–能够运用函数实现模块化编程。
–能够使用数组存储和管理数据。
–能够运用指针处理内存地址和数据。
3.情感态度价值观目标:–培养学生的编程兴趣和自信心。
–培养学生解决问题的能力和创新精神。
–培养学生团队合作和交流分享的意识。
二、教学内容本节课的教学内容主要包括C语言的基本语法、数据类型、函数、数组和指针。
具体安排如下:1.C语言的基本语法和数据类型:介绍C语言的构成要素,包括变量、常量、运算符、表达式等。
2.函数的定义和调用:讲解函数的声明、定义和调用方式,并通过实例演示函数的使用。
3.数组的声明和使用:介绍数组的声明、初始化和使用方法,并通过实例展示数组在超市管理系统中的应用。
4.指针的概念和应用:讲解指针的定义、声明和使用,并通过实例说明指针在超市管理系统中的应用。
三、教学方法本节课采用多种教学方法,以激发学生的学习兴趣和主动性:1.讲授法:通过讲解C语言的基本语法、数据类型、函数、数组和指针的概念和用法。
2.案例分析法:通过分析超市管理系统的实际案例,引导学生运用C语言编程解决实际问题。
3.实验法:安排课堂实验,让学生动手实践,加深对C语言编程的理解和应用。
4.讨论法:学生分组讨论,促进学生之间的交流与合作,培养团队合作精神。
四、教学资源本节课所需的教学资源包括:1.教材:选用权威、实用的C语言教材,为学生提供系统、全面的学习资料。
2.参考书:提供相关领域的参考书籍,拓展学生的知识面。
3.多媒体资料:制作课件、教学视频等多媒体资料,增强课堂教学的趣味性和生动性。
4.实验设备:准备计算机、编程环境等实验设备,确保学生能够动手实践。
超市食品管理系统c语言实验报告

超市食品管理系统c语言实验报告超市食品管理系统C语言实验报告一、实验目的本实验旨在让学生通过设计和实现一个超市食品管理系统,初步了解和掌握C语言编程的基本知识和技能,并培养学生独立思考和解决问题的能力。
二、实验内容本实验的主要内容是设计和实现一个超市食品管理系统,该系统可以实现以下功能:1. 管理员可以添加、删除、修改商品信息,如商品名称、价格、生产日期、保质期等。
2. 超市职员可以查询商品信息,并根据生产日期和保质期进行预警提醒。
3. 管理员可以生成商品销售报表,并显示每种商品的日销售量和总销售量。
4. 超市职员可以录入顾客购物清单,生成购物结算单,并计算折扣和总价。
三、实验原理本实验的实现主要依靠C语言编程语言,并借助各种相关函数库和工具,如文件IO操作函数、结构体定义和使用、条件和循环语句等。
四、实验过程1. 首先,我们开始设计和实现商品信息的添加功能。
为此,我们定义一个结构体类型goods,包含商品名称、价格、生产日期、保质期等信息。
然后,我们定义一个函数add_goods,用于添加商品信息。
该函数利用文件IO操作函数将商品信息写入一个文本文件,并对商品信息进行检验,以确保数据的准确性和完整性。
2. 接下来,我们实现商品信息的查询和预警提醒功能。
为此,我们定义两个函数query_goods和warning_goods。
query_goods函数利用文件IO操作函数从文本文件中读取商品信息,并根据用户输入的关键字进行模糊查询,返回匹配的商品信息。
warning_goods函数则利用当前日期和商品的生产日期和保质期计算商品的保质期,如果商品已过期或即将过期,则提醒职员及时处理。
3. 然后,我们开始设计和实现商品销售报表功能。
为此,我们定义一个函数sales_report,用于根据订单信息和商品信息计算每种商品的日销售量和总销售量。
该函数利用文件IO操作函数将销售报表写入一个文本文件,并在屏幕上显示报表信息。
超市管理系统-C语言

西安邮电大学高级语言课程设计报告题目:超市管理系统院系名称:理学院专业名称:应用物理学班级: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_id[30]; /*商品编号*/char goods_name[30]; /*商品名称*/double goods_price; /*商品价格*/double goods_discount;/*商品折扣*/int goods_amount;/*商品总数目*/int goods_remain;/*商品剩余数目*/}goods[COUNT];int count=0; /*全局变量,用于保存实际上有多少个商品*/2:欢迎界面void huanying(){printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n");printf("\t\3 欢迎使用\3\n");printf("\t\3 \3\n");printf("\t\3 \3\n");printf("\t\3 超市管理系统\3\n");printf("\t\3 \3\n");printf("\t\3 \3\n");printf("\t\3 \4\4\4\4\4\4 \3\n");printf("\t\3 \3\n");printf("\t\3 \5\5\5\5\5\5\5\5\5 \3\n");printf("\t\3 \3\n");printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n");}3:密码登陆void mima(){// char pass[6]={'1','2','3','4','5','6'};/*假设密码长度是6*/char pass[]={"123456"};/*假设密码长度是6*/char str[6],ch;int i=0;int flag=0;printf(" 请输入密码:");fflush(stdin);for(i=0;i<6;i++){ch=getch(); /*读取字符,不显示*/str[i]=ch;putchar('*');}for(i=0;i<6;i++){if(str[i]!=pass[i]){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();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);}else{printf(" You Enter The Choice Is Not valid ! \n");getch();system("cls");start();}}void huanying(){printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n");printf("\t\3 欢迎使用\3\n");printf("\t\3 \3\n");printf("\t\3 \3\n");printf("\t\3 超市管理系统\3\n");printf("\t\3 \3\n");printf("\t\3 \3\n");printf("\t\3 \4\4\4\4\4\4 \3\n");printf("\t\3 \3\n");printf("\t\3 \5\5\5\5\5\5\5\5\5 \3\n");printf("\t\3 \3\n");printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n");}5:商品信息的录入void input() /*数据录入*/{FILE *fp;char flag[20];fp=fopen("e:/student.txt","wt");do{printf("请输入你的商品信息:\n"); /*录入商品的信息*/printf("商品编号:");scanf("%s",goods[count].goods_id);printf("商品名字:");scanf("%s",goods[count].goods_name);printf("商品价格:");scanf("%lf",&goods[count].goods_price);printf("商品折扣:");scanf("%lf",&goods[count].goods_discount);printf("商品总数目:");scanf("%d",&goods[count].goods_amount);printf("商品剩余数目:");scanf("%d",&goods[count].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 ch[20],a[20];fp=fopen("e:/student.txt","rt");while(fread(&goods[m],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;i<count;i++){if(strcmp(goods[i].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",goods[i].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",&goods[i].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",&goods[i].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",&goods[i].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",&goods[i].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 ch[20],c[20];fp=fopen("e:/student.txt","rt");while(fread(&goods[m],sizeof(struct MarketGoods),1,fp)!=NULL){printf("%s",goods[m].goods_id);m++;}fclose(fp);printf("\nenter you want delete name :\n"); /*根据商品的名称来删除数据*/ printf("name:");scanf("%s",c);for(i=0;i<count;i++){if(strcmp(c,goods[i].goods_name)==0)break; /*找到,即跳出循环*/for(j=i;j<count-1;j++)goods[j]=goods[j+1];}printf("\t\t\tyou had delete %s\n",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 a[20];fp=fopen("e:/student.txt","rt");while(fread(&goods[m],sizeof(struct MarketGoods),1,fp)!=NULL){printf("%s",goods[m].goods_name);m++;}printf("\nenter you want look name:"); /*根据商品的名称来查找数据*/scanf("%s",a);for(i=0;i<m;i++){if(strcmp(goods[i].goods_name,a)==0)printf("%s %s %lf %lf %d %d \n",goods[i].goods_id,goods[i].goods_name,goods[i].goods_price,goods[i].goods_dis count,goods[i].goods_amount,goods[i].goods_remain);}getch();system("cls");start();}9:系统颜色选择void colour(){int a;printf("\n\n\t\t选择以下方案\n");printf("\n\n\t\t1**********红底黑字\n");printf("\n\n\t\t2**********白底黑子");printf("\n\n\t\t3**********黑底红字");printf("\n\n\t\t4**********绿底蓝字");printf("\n\n\t\t5**********黄底蓝字");printf("\n\n\t\t6**********系统默认");printf("\n\n\t\t\t\t请挑选您喜欢的颜色<1-6>....");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("\n\n\t\t\t\t输入无效");{getch();colour();}}start();}10:商品信息输出void output() /*数据输出*/{ FILE *fp;int i,m=0;fp=fopen("e:/student.txt","rt");while(fread(&goods[m],sizeof(struct MarketGoods),1,fp)!=NULL){m++;}fclose(fp);printf(" 编号名称价格折扣总数目剩余数目\n");for(i=0;i<m;i++){printf("%s %s %lf %lf %10d %10d \n",goods[i].goods_id,goods[i].goods_name,goods[i].goods_price,goods[i].goods_discount,goods[i].goods_amount,goods[i].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();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:调试分析调试过程中,会有很多的错误。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
超市管理系统-C语言————————————————————————————————作者:————————————————————————————————日期:西安邮电大学高级语言课程设计报告题目:超市管理系统院系名称:理学院专业名称:应用物理学班级: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_id[30]; /*商品编号*/char goods_name[30]; /*商品名称*/double goods_price; /*商品价格*/double goods_discount;/*商品折扣*/int goods_amount;/*商品总数目*/int goods_remain;/*商品剩余数目*/}goods[COUNT];int count=0; /*全局变量,用于保存实际上有多少个商品*/2:欢迎界面void huanying(){printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n");printf("\t\3 欢迎使用\3\n");printf("\t\3 \3\n");printf("\t\3 \3\n");printf("\t\3 超市管理系统\3\n");printf("\t\3 \3\n");printf("\t\3 \3\n");printf("\t\3 \4\4\4\4\4\4 \3\n");printf("\t\3 \3\n");printf("\t\3 \5\5\5\5\5\5\5\5\5 \3\n");printf("\t\3 \3\n");printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n");}3:密码登陆void mima(){// char pass[6]={'1','2','3','4','5','6'};/*假设密码长度是6*/char pass[]={"123456"};/*假设密码长度是6*/char str[6],ch;int i=0;int flag=0;printf(" 请输入密码:");fflush(stdin);for(i=0;i<6;i++){ch=getch(); /*读取字符,不显示*/str[i]=ch;putchar('*');}for(i=0;i<6;i++){if(str[i]!=pass[i]){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();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);}else{printf(" You Enter The Choice Is Not valid ! \n");getch();system("cls");start();}}void huanying(){printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n");printf("\t\3 欢迎使用\3\n");printf("\t\3 \3\n");printf("\t\3 \3\n");printf("\t\3 超市管理系统\3\n");printf("\t\3 \3\n");printf("\t\3 \3\n");printf("\t\3 \4\4\4\4\4\4 \3\n");printf("\t\3 \3\n");printf("\t\3 \5\5\5\5\5\5\5\5\5 \3\n");printf("\t\3 \3\n");printf("\t\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n");}5:商品信息的录入void input() /*数据录入*/{FILE *fp;char flag[20];fp=fopen("e:/student.txt","wt");do{printf("请输入你的商品信息:\n"); /*录入商品的信息*/printf("商品编号:");scanf("%s",goods[count].goods_id);printf("商品名字:");scanf("%s",goods[count].goods_name);printf("商品价格:");scanf("%lf",&goods[count].goods_price);printf("商品折扣:");scanf("%lf",&goods[count].goods_discount);printf("商品总数目:");scanf("%d",&goods[count].goods_amount);printf("商品剩余数目:");scanf("%d",&goods[count].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 ch[20],a[20];fp=fopen("e:/student.txt","rt");while(fread(&goods[m],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;i<count;i++){if(strcmp(goods[i].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",goods[i].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",&goods[i].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",&goods[i].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",&goods[i].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",&goods[i].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 ch[20],c[20];fp=fopen("e:/student.txt","rt");while(fread(&goods[m],sizeof(struct MarketGoods),1,fp)!=NULL){printf("%s",goods[m].goods_id);m++;}fclose(fp);printf("\nenter you want delete name :\n"); /*根据商品的名称来删除数据*/ printf("name:");scanf("%s",c);for(i=0;i<count;i++){if(strcmp(c,goods[i].goods_name)==0)break; /*找到,即跳出循环*/for(j=i;j<count-1;j++)goods[j]=goods[j+1];}printf("\t\t\tyou had delete %s\n",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 a[20];fp=fopen("e:/student.txt","rt");while(fread(&goods[m],sizeof(struct MarketGoods),1,fp)!=NULL){printf("%s",goods[m].goods_name);m++;}printf("\nenter you want look name:"); /*根据商品的名称来查找数据*/scanf("%s",a);for(i=0;i<m;i++){if(strcmp(goods[i].goods_name,a)==0)printf("%s %s %lf %lf %d %d \n",goods[i].goods_id,goods[i].goods_name,goods[i].goods_price,goods[i].goods_dis count,goods[i].goods_amount,goods[i].goods_remain);}getch();system("cls");start();}9:系统颜色选择void colour(){int a;printf("\n\n\t\t选择以下方案\n");printf("\n\n\t\t1**********红底黑字\n");printf("\n\n\t\t2**********白底黑子");printf("\n\n\t\t3**********黑底红字");printf("\n\n\t\t4**********绿底蓝字");printf("\n\n\t\t5**********黄底蓝字");printf("\n\n\t\t6**********系统默认");printf("\n\n\t\t\t\t请挑选您喜欢的颜色<1-6>....");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("\n\n\t\t\t\t输入无效");{getch();colour();}}start();}10:商品信息输出void output() /*数据输出*/{ FILE *fp;int i,m=0;fp=fopen("e:/student.txt","rt");while(fread(&goods[m],sizeof(struct MarketGoods),1,fp)!=NULL){m++;}fclose(fp);printf(" 编号名称价格折扣总数目剩余数目\n");for(i=0;i<m;i++){printf("%s %s %lf %lf %10d %10d \n",goods[i].goods_id,goods[i].goods_name,goods[i].goods_price,goods[i].goods_discount,goods[i].goods_amount,goods[i].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();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:调试分析调试过程中,会有很多的错误。