#includestdio.h#includeconio.h#includestring.h#includestdlib.h#includetime.h#defineN10//ºê#defineD10#defineH10//#definePASSWORD123#defineASK(ORDER*)malloc(sizeof(ORDER))#defineMaxCapacity4//¶¨Ò嶩µ¥½á¹¹ÌåtypedefstructOrder{intTable_ID;intDish_ID[N];structOrder*next;}ORDER;//¶¨Òå²Í×À½á¹¹ÌåtypedefstructTable{intTable_ID;intCapacity;intTable_State;}TABLE;//¶¨Òå²ËµÄ½á¹¹ÌåtypedefstructDish{intDish_ID;charDish_Name[10];floatDish_Price;}DISH;TABLEtb[H];DISHdish[D];intPASSWORD=123456;//º¯Êý¶¨ÒåvoidLoad_Dish(void);ORDER*CreateOne(int);voidDish_Menu(void);voidTable_Init(void);intsearch(void);ORDER*Dish_Order(ORDER*,ORDER*);voidDisplay(int);voidsaveInList(float);voidSave_Inform(ORDER*,int);ORDER*Payment(ORDER*);voidModifyPW(void);intPass_Word(void);voidObserve(void);voidListMenu(void);voidList_Management(void);voidMain_Menu(void);voidGet_Rank(void);voidMenu_select(void);//Ö÷º¯Êývoidmain(){Table_Init();Menu_select();}//ϵͳÖ÷²Ëµ¥voidMain_Menu(){printf(\n*********************\n);printf(²ÍÌü·þÎñϵͳ\n);printf(*********************\n);printf(1.µã²Ë\n);printf(2.¿Í»§½áÕÊ\n);printf(3.ÕÊÄ¿¹ÜÀí\n);printf(4.²ÍÌüͳ¼Æ\n);printf(5.Í˳öϵͳ\n);}//Ñ¡Ôñ¹¦ÄÜvoidMenu_select(void){ORDER*head;intchoose;intresult;head=NULL;system(cls);do{Load_Dish();Main_Menu();printf(ÇëÑ¡Ôñ:\n);fflush(stdin);scanf(%d,&choose);//system(cls);switch(choose){case1:result=search();if(result==1)printf(Äú¿ÉÒÔµ½%dºÅ²Í×À¾Í²Í\n,result);elseprintf(ÄúºÍÄúµÄÅóÓÑ¿ÉÒÔµ½%dºÅ²Í×À¾Í²Í\n,result);Dish_Menu();head=Dish_Order(head,CreateOne(result));//system(cls);break;case2:head=Payment(head);break;case3:List_Management();break;case4:Get_Rank();break;case5:exit(1);break;}}while(1);}//´ÓÎļþÖжÁÈ¡²ËÆ×voidLoad_Dish(void){FILE*fp;inti;fp=fopen(dish_name.txt,r);for(i=0;iD;i++){fscanf(fp,%d\t%s\t%f\n,&dish[i].Dish_ID,dish[i].Dish_Name,&dish[i].Dish_Price);}}//²Í×À³õʼ»¯voidTable_Init(){tb[0].Capacity=1;tb[0].Table_ID=1;tb[1].Capacity=1;tb[1].Table_ID=2;tb[2].Capacity=2;tb[2].Table_ID=3;tb[3].Capacity=2;tb[3].Table_ID=4;tb[4].Capacity=2;tb[4].Table_ID=5;tb[5].Capacity=3;tb[5].Table_ID=6;tb[6].Capacity=4;tb[6].Table_ID=7;tb[7].Capacity=4;tb[7].Table_ID=8;tb[8].Capacity=4;tb[8].Table_ID=9;tb[9].Capacity=4;tb[9].Table_ID=10;}//ÏÔʾ²ËÆ×voidDish_Menu(void){inti;printf(*********»¶ÓÑ¡¹º±¾µê²Ë**********\n);printf(²Ë±àºÅ,²ËÃû,²Ëµ¥¼Û.);for(i=0;iD;i++)printf(%d\t%s\t%f\n,dish[i].Dish_ID,dish[i].Dish_Name,dish[i].Dish_Price);}//²éÕÒÓÐûÓÐÆ¥ÅäµÄ²Í×Àintsearch(void){intCust_Num;inti;printf(ÇëÊäÈëÀ´¿ÍÊýÁ¿:\n);scanf(%d,&Cust_Num);if(MaxCapacityCust_Num){printf(±§Ç¸£¬±¾µêûÓÐÈÝÄÉ%dde²Í×À!,Cust_Num);return-1;}while(Cust_Num=MaxCapacity){for(i=0;iH;i++){if(tb[i].Table_State==0){if(tb[i].Capacity==Cust_Num)return(tb[i].Table_ID);}}printf(±§Ç¸£¬ÏÖÔÚûÓÐ%dÈË×À,Cust_Num);Cust_Num+=1;}printf(²Í×ÀÒÑÂú£¬Çë¿ÍÈËÉÔµÈÒ»»á¡£);return-1;}//´´½¨Ò»·Ý¶©µ¥ORDER*CreateOne(intresult){ORDER*p;inti;p=ASK;if(result!=-1){p-Table_ID=result;for(i=0;iD;i++){printf(ÇëÊäÈë²ËµÄ±àºÅ¡£°´0½áÊøÊäÈë:);scanf(%d,&p-Dish_ID[i]);if(p-Dish_ID[i]0||p-Dish_ID[i]10){printf(³¬³ö²ËÆ×·¶Î§£¬ÇëÖØÐÂÊäÈë\n);i--;}elseif(p-Dish_ID[i]==0)break;}tb[result-1].Table_State=1;}p-next=NULL;returnp;}//Ìí¼Óµ½Ö÷Á´ORDER*Dish_Order(ORDER*head,ORDER*p){ORDER*p1;p1=head;if(p1!=NULL){if(p!=NULL){while(p1-next!=NULL){p1=p1-next;}p1-next=p;printf(¶©µ¥´´½¨³É¹¦\n);}elseprintf(¶©µ¥´´½¨Ê§°Ü\n);}else{if(head==NULL&&p!=NULL)head=p;}returnhead;}//¸ù¾Ý²ËµÄ±àºÅ´òÓ¡Ò»µÀ²ËµÄÐÅÏ¢voidDisplay(intID){inti=0;for(i=0;iD;i++){if(dish[i].Dish_ID==ID){printf(%d\t%s\t%f\n,dish[i].Dish_ID,dish[i].Dish_Name,dish[i].Dish_Price);break;}}}//½«Ïû·Ñ¶îдÈëÕ˵¥voidsaveInList(floatpay){FILE*fp;time_ttimer;timer=time(NULL);if((fp=fopen(Õ˱¾.txt,a))==NULL){printf(²Ù×÷ʧ°Ü\n);exit(1);}fprintf(fp,%f\t%s\n,pay,ctime(&timer));//ϵͳʱ¼äÓÐÎÊÌâprintf(Õ˱¾±£´æ³É¹¦\n);fclose(fp);}//½«ÒѽáÕË¿Í»§Ð´ÈëÀúÊ·¼Ç¼voidSave_Inform(ORDER*p,intm){FILE*fp;time_ttimer;inti=0;timer=time(NULL);if((fp=fopen(ÀúÊ·¼Ç¼.txt,a))==NULL){printf(²Ù×÷ʧ°Ü\n);exit(1);}fprintf(fp,%d\n,m);while(p-Dish_ID[i]0){fprintf(fp,%d\t%s\t%f\n,dish[p-Dish_ID[i]-1].Dish_ID,dish[p-Dish_ID[i]-1].Dish_Name,dish[p-Dish_ID[i]-1].Dish_Price);i++;}fprintf(fp,%s,ctime(&timer));printf(ÀúÊ·¼Ç¼±£´æ³É¹¦\n);}//½áÕËORDER*Payment(ORDER*head){inti=0;intcount=0;floatpay=0.0;floatPay;intID;ORDER*p,*p1;p=head;printf(ÇëÊäÈëÄúµÄ²Í×ÀºÅ\n);fflush(stdin);scanf(%d,&ID);while(p!=NULL){if(p-Table_ID==ID){printf(Äúµã²ËµÄÇé¿öÈçÏÂ:\n);printf(±àºÅ\t²ËÃû\t¼Û¸ñ\n);while(p-Dish_ID[i]!=0){Display(p-Dish_ID[i]);pay+=dish[p-Dish_ID[i]-1].Dish_Price;i++;count++;}printf(ÄúÒ»¹²µãÁË%dµÀ²Ë\n,count);printf(Äú±¾´ÎµÄÏû·Ñ¶îΪ%fÔª\n,pay);printf(Äúʵ¼ÊµÄ¸¶¿î:\n);scanf(%f,&Pay);if(Paypay)printf(ÕÒÄú%f\n,Pay-pay);printf(ллÄúµÄ»Ý¹Ë£¬»¶ÓÏ´ιâÁÙ\n);if(count0){saveInList(pay);Save_Inform(p,count);}tb[p-Table_ID].Table_State=0;break;}else{p1=p;p=p-next;}}if(p==head)head=head-next;elsep1-next=p-next;free(p);returnhead;}//ÐÞ¸ÄÃÜÂëvoidModifyPM(){intpassword;printf(ÇëÊäÈëеÄÃÜÂë\n);scanf(%d,&password);PASSWORD=password;printf(ÃÜÂëÐ޸ijɹ¦\n);}//²é¿´ÕËÄ¿voi