#includestdio.h#includestdlib.h#includestring.h#includeconio.hstructThing{intid;charname[30];charproduce[30];intnumber;floatprice;chartype[30];};voidtianjia();voidshanchu();voidxiugai();voidchaxun();voidchazhao();voidliulan();voidtuichu();voidinitialization(){FILE*fp;structThingi={1,牛奶,辽宁,1200,3};fp=fopen(Thing.dat恶,w);if(fp==NULL){printf(\t\t\t系统错误,请重试........);exit(0);}fwrite(&i,sizeof(structThing),1,fp);fclose(fp);}voidmenu(){intchoice;printf(\n∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞【超市管理系统】∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞\n);printf(------------------------------系统菜单-------------------------------);printf(\n\t①=====================【新购物品入库】\n);printf(\n\t②=====================【物品信息删除】\n);printf(\n\t③=====================【物品信息修改】\n);printf(\n\t④=====================【利用编号查询】\n);printf(\n\t⑤=====================【利用种类查找】\n);printf(\n\t⑥=====================【物品信息浏览】\n);printf(\n\t⑦=====================【应用程序退出】\n);printf(\n\t请输入您要选择的菜单......);scanf(%d,&choice);switch(choice){case1:tianjia();break;case2:shanchu();break;case3:xiugai();break;case4:chaxun();break;case5:chazhao();break;case6:liulan();break;case7:tuichu();break;default:printf(\n\t\t\t\t\t输入无效,请您重新输入......);getch();system(cls);menu();}}intvalidateID(intid){FILE*fp;structThingi;fp=fopen(Thing.date,r);if(fp==NULL){printf(\t\t\t系统错误,请您重试........);exit(0);}fread(&i,sizeof(structThing),1,fp);while(!feof(fp)){if(i.id==id){fclose(fp);return1;break;}fread(&i,sizeof(structThing),1,fp);}fclose(fp);return0;}voidtianjia(){structThingi;charchoice;FILE*fp;fp=fopen(Thing.date,ab);if(fp==NULL){printf(\t\t\t系统错误,请您重试........);exit(0);}labID:printf(\n\t请您输入要入库物品的信息...\n);printf(\t\t\t\t物品的编号:);scanf(%d,&i.id);if(validateID(i.id)==1){printf(\t\t\t\t此编号已被使用,请您重新输入......);gotolabID;}printf(\t\t\t\t物品的名称:);scanf(%s,i.name);printf(\t\t\t\t物品的生产地:);scanf(%s,i.produce);printf(\t\t\t\t物品的数量:);scanf(%d,&i.number);printf(\t\t\t\t物品的单价:);scanf(%f,&i.price);printf(\t\t\t\t物品的种类:);scanf(%s,i.type);fwrite(&i,sizeof(structThing),1,fp);fclose(fp);printf(\t\t\t\t\t\t物品信息已入库成功!!!\n);printf(\n您想继续吗?(y/n));scanf(%c,&choice);if(choice=='Y'||choice=='y'){tianjia();}else{system(cls);menu();}}voidshanchu(){structThingi[1000];structThingtemp;intshanchuID;charchoice;intindex=0;intj=0;FILE*fp;fp=fopen(Thing.date,r);if(fp==NULL){printf(\t\t\t系统错误,请您重试........);exit(0);}fread(&temp,sizeof(structThing),1,fp);while(!feof(fp)){i[index]=temp;index++;fread(&temp,sizeof(structThing),1,fp);}fclose(fp);printf(\n\t请输入要删除的物品的编号:);scanf(%d,&shanchuID);fopen(f:\\Thing.date,w);if(fp==NULL){printf(\t\t\t系统错误,请您重试........);exit(0);}for(j=0;jindex;j++){if(i[j].id!=shanchuID){fwrite(&i[j],sizeof(structThing),1,fp);}}fclose(fp);printf(\t\t\t\t\t物品信息已清除!!!\n);printf(\n您想继续吗?(y/n));scanf(%c,&choice);if(choice=='Y'||choice=='y'){shanchu();}else{system(cls);menu();}}voidxiugai(){intindex=0;intID,j;charchoice;structThingi[1000];structThingtemp;FILE*fp;fp=fopen(Thing.date,r);if(fp==NULL){printf(\t\t\t系统错误,请您重试........);exit(0);}fread(&temp,sizeof(structThing),1,fp);while(!feof(fp)){i[index]=temp;index++;fread(&temp,sizeof(structThing),1,fp);}fclose(fp);fp=fopen(Thing.date,w);if(fp==NULL){printf(\\t\t\t系统错误,请您重试........);exit(0);}printf(\n\t请输入要修改的信息的物品的编号:);scanf(%d,&ID);for(j=0;j=index-1;j++){if(i[j].id!=ID){fwrite(&i[j],sizeof(structThing),1,fp);}else{printf(\t\t物品名称修改为:);scanf(%s,i[j].name);printf(\t\t物品生产地修改为:);scanf(%s,i[j].produce);printf(\t\t物品数量修改为:);scanf(%d,&i[j].number);printf(\t\t物品单价修改为:);scanf(%f,&i[j].price);printf(\t\t物品种类修改为:);scanf(%s,i[j].type);fwrite(&i[j],sizeof(structThing),1,fp);}}fclose(fp);printf(\t\t\t\t物品信息已修改......);printf(\n您想继续吗?(y/n));scanf(%c,&choice);if(choice=='Y'||choice=='y'){xiugai();}else{system(cls);menu();}}voidchaxun(){FILE*fp;intchaxunID;charchoice;structThingi;fp=fopen(Thing.date,r);if(fp==NULL){printf(\t\t\t系统错误,请你重试........);exit(0);}chaxunID:printf(\n\t请输入要查询的物品的编号..);scanf(%d,&chaxunID);fread(&i,sizeof(structThing),1,fp);while(!feof(fp)){if(i.id==chaxunID){printf(\n\n\t***************物品信息******************);printf(\n\t物品编号...%30d\n,i.id);printf(\n\t-----------------------------------------);printf(\n\t物品名称...%30s\n,i.name);printf(\n\t-----------------------------------------);printf(\n\t生产厂家...%30s\n,i.produce);printf(\n\t-----------------------------------------);printf(\n\t进口数量...%30d\n,i.number);printf(\n\t-----------------------------------------);printf(\n\t批发价格...%30.3f\n,i.price);printf(\n\t-----------------------------------------);printf(\n\t物品种类...%30s\n,i.type);printf(\n\t-----------------------------------------);printf(\n您想继续吗?(y/n));scanf(%c,&choice);if(choice=='Y'||choice=='y'){chaxun();}else{system(cls);menu();}}fread(&i,sizeof(structThing),1,fp);}fclose(fp);printf(\t\t\t\t\t输入的编号不存在,请您重新输入......);gotochaxunID;}voidchazhao(){FILE*fp;charchazhaoTYPE;charchoice;structThingi;fp=fopen(Thing.date,r);if(fp==NULL){printf(\t\t\t系统错误,请你重试........);exit(0);}chazhaoTYPE:printf(\n\t请输入要查找的物品的种类..);scanf(%s,&chazhaoTYPE);fread(&i,sizeof(structThing),1,fp);while(!feof(fp)){if(i.type){printf(\n\n\t******