您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 酒店餐饮 > 药房管理系统c语言代码
#includestdio.h#includestdlib.h#includestring.h#defineSIZE4structmedicine{intnumber;charname[20];intsell;intqualityguaranteeperiod;intcategory;intstorage;}med[SIZE];voidmain(){intn,m,p;voidinput_the_medicine_information(structmedicinemed[]);/*输入药品信息*/voidprintf_all_the_information_of_the_medicines(structmedicinemed[]);/*查看全部药品的信息*/voidprintf_the_medicine_information(structmedicinemed[]);/*查看某一药品的信息(按药品的默认序号查看)*/voidprintf_the_medicine_informationt(structmedicinemed[]);/*查看某一药品的信息(按药品的编号进行查看)*/voidchange_the_medicine_information(structmedicinemed[]);/*修改药品信息(按药品的默认序号修改)*/voidchange_the_medicine_informationt(structmedicinemed[]);/*修改药品信息(按药品的编号进行修改)*/voidjudge_the_medicine_category();/*判断药品的性质*/voidtake_the_rank_of_sell(structmedicinemed[]);/*药品销售排序*/voidtake_the_rank_of_storage(structmedicinemed[]);/*药品库存排序*/while(1){printf(\n);printf(======欢迎来到药房管理系统=======\n);printf(****1输入药品信息****\n);printf(****2查看药品信息****\n);printf(****3修改药品信息****\n);printf(****4判断药品性质****\n);printf(****5药品销量排序****\n);printf(****6药品库存排序****\n);printf(=================================\n);printf(\n);printf(请输入你将进行操作的选项序号\n);scanf(%d,&n);switch(n){case1:printf(请输入药品信息\n);input_the_medicine_information(med);break;case2:printf(******************************************\n);printf(查看药品信息\n);printf(1查看全部药品的信息\n);printf(2查看某一药品的信息(按药品的默认序号查看)\n);printf(3查看某一药品的信息(按药品的编号进行查看)\n);printf(******************************************\n);printf(\n);printf(请输入你将进行操作的选项序号\n);scanf(%d,&m);switch(m){case1:printf_all_the_information_of_the_medicines(med);break;case2:printf(请输入要查看药品的默认序号\n);printf_the_medicine_information(med);break;case3:printf(请输入要查看药品的编号\n);printf_the_medicine_informationt(med);break;default:printf(输入有误,请重新输入\n);}break;case3:printf(*************************************\n);printf(修改药品信息\n);printf(1修改药品信息(按药品的默认序号修改)\n);printf(2修改药品信息(按药品的编号进行修改)\n);printf(*************************************\n);printf(\n);printf(请输入你将进行操作的选项序号\n);scanf(%d,&p);switch(p){case1:printf(请输入要修改的药品默认序号\n);change_the_medicine_information(med);break;case2:printf(请输入要修改的药品编号\n);change_the_medicine_informationt(med);break;default:printf(输入有误,请重新输入\n);}break;case4:judge_the_medicine_category();break;case5:take_the_rank_of_sell(med);break;case6:take_the_rank_of_storage(med);break;default:printf(输入有误,请重新输入\n);}}}/*输入药品信息*/voidinput_the_medicine_information(structmedicinemed[]){FILE*fp;if((fp=fopen(d:\\input_the_medicine_information.txt,w))==NULL){printf(cannotestablishthefile!\n);exit(0);}printf(请输入药品的numbernamesellqualityquaranteeperiodcategorystorage\n);for(inti=0;iSIZE;i++){scanf(%d,&med[i].number);scanf(%s,med[i].name);scanf(%d,&med[i].sell);scanf(%d,&med[i].qualityguaranteeperiod);scanf(%d,&med[i].category);scanf(%d,&med[i].storage);}for(i=0;iSIZE;i++)if(fwrite(&med[i],sizeof(structmedicine),1,fp)!=1)printf(filewriteerror\n);fclose(fp);}/*查看全部药品的信息()*/voidprintf_all_the_information_of_the_medicines(structmedicinemed[]){FILE*fp;inti;fp=fopen(d:\\input_the_medicine_information.txt,r);printf(查看全部药品的简略信息:\n);printf(\n);printf(***********************************************************************\n);printf(默认序号numbernamesellqualityguaranteeperiodcategorystorage\n);for(i=0;iSIZE;i++){fread(&med[i],sizeof(structmedicine),1,fp);printf(%6d%8d%8s%6d%11d%22d%8d\n,i,med[i].number,med[i].name,med[i].sell,med[i].qualityguaranteeperiod,med[i].category,med[i].storage);printf(\n);}printf(***********************************************************************\n);fclose(fp);}/*查看某一药品的信息(按药品的默认序号查看)*/voidprintf_the_medicine_information(structmedicinemed[]){FILE*fp;inti;fp=fopen(d:\\input_the_medicine_information.txt,r);for(i=0;iSIZE;i++){fread(&med[i],sizeof(structmedicine),1,fp);}intg;scanf(%d,&g);if(gSIZE){printf(*************************************************************\n);printf(numbernamesellqualityguaranteeperiodcategorystorage\n);printf(%d%s%d%d%d%d\n,med[g].number,med[g].name,med[g].sell,med[g].qualityguaranteeperiod,med[g].category,med[g].storage);printf(*************************************************************\n);}else{printf(*************************************************************\n);printf(numbernamesellqualityguaranteeperiodcategorystorage\n);printf(000000\n);printf(*************************************************************\n);}fclose(fp);}/*查看某一药品的信息(按药品的编号查看)*/voidprintf_the_medicine_informationt(structmedicinemed[]){FILE*fp;inti;fp=fopen(d:\\input_the_medicine_information.txt,r);for(i=0;iSIZE;i++){fread(&med[i],sizeof(structmedicine),1,fp);}inth;scanf(%d,&h);intj=0;for(i=0;iSIZE;i++){if(med[i].number==h){printf(*************************************************************\n);printf(numbernamesellqualityguaranteeperiodcategorystorage\n);printf(%d%s%d%d%d%d\n,med[i].number,med[i].name,med[i].sell,med[i].qualityguaranteeperiod,med[i].category,med[i].storage);printf(*************************************************************\n);j=1;}}if(j==0){printf(*************************************************************\n);printf(numbernamesellqualitygu
本文标题:药房管理系统c语言代码
链接地址:https://www.777doc.com/doc-4032362 .html