超市管理系统c语言课程设计(编辑修改稿)内容摘要:

oods()。 break。 case39。 339。 : updategoods()。 break。 case39。 439。 : delgoods()。 break。 case39。 539。 : showMymenue()。 break。 default: printf(\n您的输入有误,请检查后重新输入 \n)。 pcontinue()。 } } } void showCustmenue(){ char choice=39。 539。 while(1){ system(cls)。 BreakLine。 printf(\t\t1. 添加客户 \n)。 printf(\t\t2. 查找客户 \n)。 printf(\t\t3. 修改客户 \n)。 printf(\t\t4. 删除客户 \n)。 printf(\t\t5. 返回上一级 \n)。 BreakLine。 printf(\n\n 请输入您的选择 (1,2,3,4,5):)。 choice=getch()。 switch (choice){ case39。 139。 : addcust()。 break。 case39。 239。 : findall()。 break。 case39。 339。 : updatecust()。 break。 case39。 439。 : delcust()。 break。 case39。 539。 : showMymenue()。 break。 default: printf(\n您的输入有误,请检查后重新输入 \n)。 pcontinue()。 } 超市管理系统 C 语言课程设计 } } void showSales(){ char choice=39。 539。 while(1){ system(cls)。 BreakLine。 printf(\t\ VIP客户排行榜 \n)。 printf(\t\ \n)。 printf(\t\ \n)。 printf(\t\ \n)。 printf(\t\ \n)。 BreakLine。 printf(\n\t\t请输入您的选择 (1,2,3,4,5):)。 choice=getch()。 switch(choice){ case 39。 139。 : showVIP()。 break。 case 39。 239。 : Goodseffect()。 break。 case 39。 339。 : Goodssave()。 break。 case 39。 439。 : Birthdayperson()。 break。 case 39。 539。 : showMymenue()。 break。 default: printf(\n\t\t您的输入有误,请确认重新输入 .\n)。 pcontinue()。 }//调用按任意键继续 } } void showSell(){ char choice=39。 239。 while(1){ system(cls)。 BreakLine。 printf(\t\ \n)。 超市管理系统 C 语言课程设计 printf(\t\ \n)。 BreakLine。 printf(\n\t\t请输入您的选择 (1,2,):)。 choice=getch()。 switch(choice){ case 39。 139。 : shopping()。 break。 case 39。 239。 : showMymenue()。 break。 default: printf(\n\t\t您的输入有误,请确认重新输入 .\n)。 pcontinue()。 } //调用按任意键继续 } } 4. include include include include include include include include read_message()。 struct data{ int year。 int month。 int day。 }。 struct cust{ int no。 //编号 char name[20]。 //名字 double expenditure。 //总花费 char tel[20]。 //电话号码 struct data birthday。 //生日 超市管理系统 C 语言课程设计 }cust[1000]。 //最多存 1000 个客户信息 int total。 //现在 文件中总的纪录条数 void saveAll(){ FILE*fp。 int i。 if((fp=fopen(,wb))==NULL){ printf(\n 无法打开文件 \n)。 return。 } for(i=0。 itotal。 i++){ fwrite(amp。 cust[i],sizeof(struct cust),1,fp)。 } fclose(fp)。 }// 获取现有文件中客户的总人数 int read_message(){ FILE*fp。 int i=0。 //记数 //打开文件 if((fp=fopen(,rb))==NULL){ printf(\n******暂无任何可读消息 ,按任意键继续 *****\n)。 getch()。 return 0。 } while(!feof(fp)){ fread(amp。 cust[i],sizeof(struct cust), 1, fp)。 if(cust[i].no==0){ break。 }else {i++。 } } //循环读取文件中的每一条记录 fclose(fp)。 return i。 //存到 cust 结构中 超市管理系统 C 语言课程设计 } void addcust(){ //定义增加的 struct cust newcust。 char choice=39。 y39。 FILE *fp。 int i=0。 do{ system(cls)。 BreakLine。 printf(请输入客户的编号 :)。 scanf(%d,amp。 )。 printf(\n)。 printf(请输入客户的名字 :)。 scanf(%s,)。 printf(\n)。 printf(请输入客户消费 :)。 scanf(%lf,amp。 )。 printf(\n)。 printf(请输入客户的电话号码 :)。 scanf(%s,)。 printf(\n)。 printf(请输入客户的生日 :(格式 :199999))。 scanf(%d%d%d,amp。 ,amp。 onth,amp。 )。 printf(\n)。 BreakLine。 if((fp=fopen(,ab))==NULL){ printf(\n对不起 ,不能打开指定的文件 \n)。 return。 } fwrite(amp。 newcust,sizeof(struct cust),1,fp)。 超市管理系统 C 语言课程设计 fclose(fp)。 printf(您还要继续输入新客户信息吗 ?(y/n))。 choice=getch()。 } while(choice==39。 y39。 )。 } void findall(){ //定义查询所有的 int i。 struct cust c。 total= read_message()。 system(cls)。 printf(\n***************客户信息 **************\n)。 printf(\n 客户总数: %d\n,total)。 if(total0){ printf(\n***********显示所有客户信息 *************\n)。 printf(\n 编号 \t 姓名 \t 消费 \t\t 电话 \t\t 生日 )。 for(i=0。 itotal。 i++){ c=cust[i]。 printf(\n %d\t %s\t %lf\t %s\t %d%d%d\t\n,,)。 printf(\n\n\n\n\n)。 } }else {printf(\n********系统中暂无任何客户信息 **********)。 } pcontinue()。 getch()。 } void updatecust(){ int i。 int toupdateno。 //要更新的编号 int j。 system(cls)。 total=read_message()。 // 读出信息 printf(\n 请输入您要更新的客户编号 :)。 超市管理系统 C 语言课程设计 scanf(%d,amp。 toupdateno)。 //查找 for(i=0。 itotal。 i++){ if(toupdateno==cust[i].no){ break。 } } //i里面记录了要更新的客户的索引 if(i==total){ printf(\n 没有找到要更新的客户 \n)。 printf(按任意键继续 \n)。 getch()。 return。 } printf(\n**********请更新用户信息 **********\n)。 printf(请输入客户姓名 :)。 scanf(%s,cust[i].name)。 printf(请输入客户消费 :)。 scanf(%d,amp。 cust[i].expenditure)。 printf(请输客户电话 :)。 scanf(%s,cust[i].tel)。 printf(请输入客户的生日 (格式: 199999):)。 scanf(%d%d%d,amp。 cust[i].,amp。 cust[i].,amp。 cust[i].)。 BreakLine。 saveAll()。 printf(\n更新客户信息成功,按任意键继续 \n)。 getch()。 } void delcust(){ int i。 int todelno。 //删除客户的编号 int j。 char choice=39。 n39。 //记录是否真正删除 system(cls)。 total=read_message()。 //先读出数据 超市管理系统 C 语言课程设计 printf(\n请输入您要删除的客户的编号 :)。 scanf(%d, amp。 todelno)。 for(i=0。 itotal。 i++){ if(todelno==cust[i].no){ break。 } } if(i==total){ printf(\n没有找到您要删除的客。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。