欢迎来到天天文库
浏览记录
ID:33143685
大小:57.50 KB
页数:12页
时间:2019-02-21
《用c语言编写商品管理》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、个人收集整理勿做商业用途#include#include#include#include#include#defineLENsizeof(structcommdity)#defineFORMAT"%-8d%-15s%-12.11f%-12.11f%-12.11f"文档来自于网络搜索#defineDATAcomm[i].num,comm[i].name,comm[i].price,comm[i].count,comm[i].total文档来自
2、于网络搜索/*定义商品地结构体*/structcommdity{intnum;charname[15];doublecount;doubletotal;}comm[100000],t;/*函数地声明*/voidin();/*商品录入并保存*/voidshow();/*显示商品记录*/voidorder();/*商品记录排序*/voiddel();/*商品记录删除*/voidmodify();/*商品记录修改*/voidmenu();/*主菜单*/voidinsert();/*商品记录插入*/voidtotal();/*商品统计*/v
3、oidsearch();/*查看商品记录*/voidmain(){intn;menu();scanf("%d",&n);while(n){switch(n){case0:break;case1:in();break;case2:search();break;case3:del();break;case4:modify();break;个人收集整理勿做商业用途case5:insert();break;case6:order();break;case7:total();break;default:printf("error!操作错误..
4、...");break;}getch();menu();scanf("%d",&n);}}/**************************自定义主菜单函数************************/文档来自于网络搜索voidmenu(){system("cls");/*清屏*/printf("");printf("tt--------欢迎将进入商品管理系统----------------");文档来自于网络搜索printf("tt
5、t0.退出
6、");printf("tt
7、t
8、1.录入记录
9、");printf("tt
10、t2.查找记录
11、");printf("tt
12、t3.删除记录
13、");printf("tt
14、t4.修改记录
15、");printf("tt
16、t5.插入记录
17、");printf("tt
18、t6.排序记录
19、");printf("tt
20、t7.统计记录
21、");printf("tt
22、--------------------------------------------
23、");文档来自于网络搜索printf("ttt请输入您地操作类型
24、【0-7】:");}/**************************自定义商品录入并保存函数************************/文档来自于网络搜索voidin(){inti,m=0;charch[2];FILE*fp;if((fp=fopen("data.txt","ab+"))==NULL){printf("不能打开文件!");return;}while(!feof(fp)){if(fread(&comm[m],LEN,1,fp)==1)m++;个人收集整理勿做商业用途}fclose(fp);if(m=
25、=0)printf("无商品记录........");else{system("cls");show();}if((fp=fopen("data.txt","wb"))==NULL){printf("不能打开文件!");return;}for(i=0;i26、27、strcmp(ch,"y")==0){printf("编号:");scanf(28、"%d",&comm[m].num);for(i=0;i
26、
27、strcmp(ch,"y")==0){printf("编号:");scanf(
28、"%d",&comm[m].num);for(i=0;i
此文档下载收益归作者所有