基于c語言的購物系統(tǒng)_第1頁
基于c語言的購物系統(tǒng)_第2頁
基于c語言的購物系統(tǒng)_第3頁
基于c語言的購物系統(tǒng)_第4頁
基于c語言的購物系統(tǒng)_第5頁
已閱讀5頁,還剩70頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<time.h>#include<string.h>/************************************************************--結(jié)構(gòu)體聲明--*******************************************************************/structyonghu{ charname[20]; //用戶名 charmima[20]; //密碼 charzhifu[20]; //支付密碼 charmibao[20]; //密保問題 intmoney; //金錢余額 structyonghu*next; //地址指針};typedefstructyonghuYH;//賣家信息structmaijia{ charname[20]; //用戶名 charmima[20]; //密碼 charzhifu[20]; //支付密碼 charmibao[20]; //密保問題 intmoney; //金錢余額 structmaijia*next; //地址指針};typedefstructmaijiaMJXX;//乳品structrupin{ charpinming[100]; //品名 intjiage; //價(jià)格 charguige[20]; //規(guī)格 intkucun; //庫存 intxiaoliang; //銷量 structrupin*next; //地址指針};typedefstructrupinRP;//酒水structjiushui{ charpinming[100]; //品名 intjiage; //價(jià)格 charguige[20]; //規(guī)格 intkucun; //庫存 intxiaoliang; //銷量 structjiushui*next; //地址指針};typedefstructjiushuiJS;//堅(jiān)果structjianguo{ charpinming[100]; //品名 intjiage; //價(jià)格 charguige[20]; //規(guī)格 intkucun; //庫存 intxiaoliang; //銷量 structjianguo*next; //地址指針};typedefstructjianguoJG;//糕點(diǎn)structgaodian{ charpinming[100]; //品名 intjiage; //價(jià)格 charguige[20]; //規(guī)格 intkucun; //庫存 intxiaoliang; //銷量 structgaodian*next; //地址指針};typedefstructgaodianGD;//.蜜餞structmijian{ charpinming[100]; //品名 intjiage; //價(jià)格 charguige[20]; //規(guī)格 intkucun; //庫存 intxiaoliang; //銷量 structmijian*next; //地址指針};typedefstructmijianMJ;//糖果structtangguo{ charpinming[100]; //品名 intjiage; //價(jià)格 charguige[20]; //規(guī)格 intkucun; //庫存 intxiaoliang; //銷量 structtangguo*next; //地址指針};typedefstructtangguoTG;//傳遞商品給賣家structchuandi{ charpinming[100]; //品名 intjiage; //價(jià)格 charguige[20]; //規(guī)格 charzhuzhi[100]; //買家地址 chardianhua[20]; //買家電話 structchuandi*next; //地址指針};typedefstructchuandiCD;//購物車structgouwuche{ charyyhh[20]; //用戶名 charpinming[100]; //品名 intjiage; //價(jià)格 charguige[20]; //規(guī)格 structgouwuche*next; //地址指針};typedefstructgouwucheGWC;//篩選用戶購物車structzhuanshu{ inta; charb[100]; structzhuanshu*next;};typedefstructzhuanshuZS;//*************************************************************--函數(shù)聲明--*****************************************************************************/voidyijicaidan(); //菜單voiderjicaidan(YH*p); //二級(jí)菜單voiddenglu(); //登錄二級(jí)菜單voidyouke(); //游客登錄二級(jí)菜單voidzhuce(); //新用戶注冊(cè)voidxiugaimima(YH*a); //修改用戶密碼voidwangjimima(); //忘記密碼voidyonghuWrite(YH*head); //寫入用戶文件voidmaijiachushihua(); //賣家信息初始化voidyhchongzhi(YH*head); //用戶充值voidgoumai1(YH*p,RP*head); //購物voidgoumai2(YH*p,JS*head);voidgoumai3(YH*p,JG*head);voidgoumai4(YH*p,GD*head);voidgoumai5(YH*p,MJ*head);voidgoumai6(YH*p,TG*head);voidrp(YH*p); //三級(jí)菜單(乳品)voidrupinWrite(RP*head);RP*rupinRead();voidrpChushihua();voidjs(YH*p); //三級(jí)菜單(酒水)voidjiushuiWrite(JS*head);JS*jiushuiRead();voidjsChushihua();voidjg(YH*p); //三級(jí)菜單(堅(jiān)果)voidjianguoWrite(JG*head);JG*jianguoRead();voidjgChushihua();voidgd(YH*p); //三級(jí)菜單(糕點(diǎn))voidgaodianWrite(GD*head);GD*gaodianRead();voidgdChushihua();voidmj(YH*p); //三級(jí)菜單(蜜餞)voidmijianWrite(MJ*head);MJ*mijianRead();voidmjChushihua();voidtg(YH*p); //三級(jí)菜單(糖果)voidtangguoWrite(TG*head);TG*tangguoRead();voidtgChushihua();voidchuandisp(YH*p,char*ar); //傳遞商品voidcdWrite(CD*head);voidcdChushihua();voidckgouwuche(); //購物車voidgouwuche(YH*p1,char*ar);voidgwcWrite(GWC*head);voidgouwuchecsh(); //購物車初始化文件CD*cdRead();GWC*gwcRead();//賣家voidmaijiaWrite(); //寫入賣家文件voidmaijia(); //賣家菜單voidmaijia(); //賣家登錄MJXX*maijiaRead(); //讀取賣家文件YH*yonghuRead(); //讀用戶文件voidyonghuchushihua(); //用戶信息初始化voidmaijiazhuce();voidmjwangjimima();voidmjerjicaidan(MJXX*p);voidrp1(MJXX*p);voidjs1(MJXX*p);voidjg1(MJXX*p);voidgd1(MJXX*p);voidmj1(MJXX*p);voidtg1(MJXX*p);voidckdingdan(MJXX*p);//游客voidrp2();voidjs2();voidjg2();voidgd2();voidmj2();voidtg2();/****************************************************--主菜單--************************************************************************/voidmain(){ //cdChushihua(); //rpChushihua();//商品初始化 //jsChushihua(); //jgChushihua(); //gdChushihua(); //mjChushihua(); //tgChushihua(); //maijiachushihua(); //yonghuchushihua(); //gouwuchecsh(); yijicaidan();}//一級(jí)菜單(登錄界面)voidyijicaidan(){ intcai=0; printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n\n"); printf("\t\t┌--------------------------------------┐\n"); printf("\t\t‖\t\t\t\t\t‖\n"); printf("\t\t‖\t1.用戶登錄\t\t‖\n"); printf("\t\t‖\t\t\t\t\t‖\n"); printf("\t\t‖\t2.新用戶體驗(yàn)\t\t‖\n"); printf("\t\t‖\t\t\t\t\t‖\n"); printf("\t\t‖\t3.新用戶注冊(cè)\t\t‖\n"); printf("\t\t‖\t\t\t\t\t‖\n"); printf("\t\t‖\t4.賣家登錄\t\t‖\n"); printf("\t\t‖\t\t\t\t\t‖\n"); printf("\t\t‖\t5.退出\t\t‖\n"); printf("\t\t‖\t\t\t\t\t‖\n"); printf("\t\t└--------------------------------------┘\n\n\t\t"); cai=_getch(); switch(cai) { case49:denglu();break; case50:youke();break; //游客 case51:zhuce();break; case52:maijia();break; case53:system("cls");break; default: //輸入的選項(xiàng)沒有 system("cls"); printf("\n\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n\n\n"); printf("\t\t┌----------------------------------┐\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t您輸入的選項(xiàng)有誤?。?!‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t按任意鍵返回重新輸入‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t└----------------------------------┘\n\n\t\t"); _getch(); system("cls"); yijicaidan(); break; }}//用戶登錄界面voiddenglu(){ chara[20],b[20],c[20],e[20],m; intd,i=0,f; YH*head=NULL,*p; head=yonghuRead(); system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^登錄界面^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); printf("\t\t請(qǐng)輸入用戶名:\t"); scanf("%s",a); printf("\n"); //密碼 printf("\t\t請(qǐng)輸入密碼:\t"); b[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { b[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { b[i++]=m; printf("*"); } } b[i]='\0'; printf("\n\n"); //驗(yàn)證碼 srand((unsignedint)time(NULL)); d=rand()%9000+1000; sprintf(c,"%d",d); printf("\t\t驗(yàn)證碼為:\t%s\n\n",c); printf("\t\t請(qǐng)輸入驗(yàn)證碼:\t"); scanf("%s",e); //判斷信息是否注冊(cè)在文件中 p=head; while(p!=NULL) { if(strcmp(p->name,a)==0) { if(strcmp(p->mima,b)==0) { if(strcmp(c,e)==0) { erjicaidan(p); } } } p=p->next; } //用戶名錯(cuò)誤 system("cls"); printf("\n\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n\n\n"); printf("\t\t┌----------------------------------┐\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t您輸入的用戶名或密碼錯(cuò)誤‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t1.重新輸入‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t2.忘記密碼‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t3.新注冊(cè)用戶‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t4.退出‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t└----------------------------------┘\n\n\t\t"); f=_getch(); if(f==50) { wangjimima(); } elseif(f==51) { zhuce(); } elseif(f==52) { system("cls"); exit(0); } else{ system("cls"); denglu(); }}//二級(jí)菜單(商品分類)voiderjicaidan(YH*p){ inta; system("cls"); printf("您的余額為:%d\t\t充值:按0充值",p->money); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^產(chǎn)品種類^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); printf("\t1.乳品\t2.酒水\n\n\t3.堅(jiān)果\t4.糕點(diǎn)\n\n\t5.蜜餞\t6.糖果\n\n\t7.查看購物車\n\n\n\t8.返回\t9.退出"); printf("\n\n\t請(qǐng)輸入您要購買的類別:"); a=_getch(); switch(a) { case48:yhchongzhi(p);break; case49:rp(p);break; case50:js(p);break; case51:jg(p);break; case52:gd(p);break; case53:mj(p);break; case54:tg(p);break; case55:ckgouwuche(p); case56:denglu();break; case57:exit(0);break; default:break; }}//三級(jí)菜單(具體商品)voidrp(YH*p){ RP*head; inti=1,a,j; system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^乳品^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=rupinRead(); while(head!=NULL) { printf("\n\t%d.商品名:%-40s價(jià)格:%-10d",i,head->pinming,head->jiage); i++; head=head->next; } printf("\n\n\t請(qǐng)輸入您的選項(xiàng):"); scanf("%d",&a); j=1; while(1) { system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^乳品^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=rupinRead(); while(a!=j) { head=head->next; j++; } printf("\t商品名:%s\n\t價(jià)格:%d\n\t規(guī)格:%s\n\t庫存:%d\n\t銷量:%d\n",head->pinming,head->jiage,head->guige,head->kucun,head->xiaoliang); printf("\n\n\t1.加入購物車\t2.立即購買\n\n\t3.返回\t\t4.退出\n\n\t請(qǐng)輸入您的操作:"); scanf("%d",&i); switch(i) { case1:gouwuche(p,head->pinming);break; case2:goumai1(p,head);break; case3:rp(p); case4:exit(0); default: break; } break; }}voidjs(YH*p){ JS*head; inti=1,a,j; system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^酒水^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=jiushuiRead(); while(head!=NULL) { printf("\n\t%d.商品名:%-40s\t價(jià)格:%-10d",i,head->pinming,head->jiage); i++; head=head->next; } printf("\n\n\t請(qǐng)輸入您的選項(xiàng):"); scanf("%d",&a); j=1; while(1) { system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^酒水^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=jiushuiRead(); while(a!=j) { head=head->next; j++; } printf("\t商品名:%s\n\t價(jià)格:%d\n\t規(guī)格:%s\n\t庫存:%d\n\t銷量:%d\n",head->pinming,head->jiage,head->guige,head->kucun,head->xiaoliang); printf("\n\n\t1.加入購物車\t2.立即購買\n\n\t3.返回\t\t4.退出\n\n\t請(qǐng)輸入您的操作:"); scanf("%d",&i); switch(i) { case1:gouwuche(p,head->pinming);break; case2:goumai2(p,head);break; case3:rp(p); case4:exit(0); default: break; } break; }}voidjg(YH*p){ JG*head; inti=1,a,j; system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^堅(jiān)果^^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=jianguoRead(); while(head!=NULL) { printf("\n\t%d.商品名:%-40s\t價(jià)格:%-10d",i,head->pinming,head->jiage); i++; head=head->next; } printf("\n\n\t請(qǐng)輸入您的選項(xiàng):"); scanf("%d",&a); j=1; while(1) { system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^堅(jiān)果^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=jianguoRead(); while(a!=j) { head=head->next; j++; } printf("\t商品名:%s\n\t價(jià)格:%d\n\t規(guī)格:%s\n\t庫存:%d\n\t銷量:%d\n",head->pinming,head->jiage,head->guige,head->kucun,head->xiaoliang); printf("\n\n\t1.加入購物車\t2.立即購買\n\n\t3.返回\t\t4.退出\n\n\t請(qǐng)輸入您的操作:"); scanf("%d",&i); switch(i) { case1:gouwuche(p,head->pinming);break; case2:goumai3(p,head);break; case3:rp(p); case4:exit(0); default: break; } break; }}voidgd(YH*p){ GD*head=NULL; inti=1,a,j; system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^糕點(diǎn)^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=gaodianRead(); while(head!=NULL) { printf("\n\t%d.商品名:%-40s\t價(jià)格:%-10d",i,head->pinming,head->jiage); i++; head=head->next; } printf("\n\n\t請(qǐng)輸入您的選項(xiàng):"); scanf("%d",&a); j=1; while(1) { system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^糕點(diǎn)^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=gaodianRead(); while(a!=j) { head=head->next; j++; } printf("\t商品名:%s\n\t價(jià)格:%d\n\t規(guī)格:%s\n\t庫存:%d\n\t銷量:%d\n\n",head->pinming,head->jiage,head->guige,head->kucun,head->xiaoliang); printf("\n\n\t1.加入購物車\t2.立即購買\n\n\t3.返回\t\t4.退出\n\n\t請(qǐng)輸入您的操作:"); scanf("%d",&i); switch(i) { case1:gouwuche(p,head->pinming);break; case2:goumai4(p,head);break; case3:rp(p); case4:exit(0); default: break; } break; }}voidmj(YH*p){ MJ*head; inti=1,a,j; system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^蜜餞^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=mijianRead(); while(head!=NULL) { printf("\n\t%d.商品名:%-40s\t價(jià)格:%-10d",i,head->pinming,head->jiage); i++; head=head->next; } printf("\n\n\t請(qǐng)輸入您的選項(xiàng):"); scanf("%d",&a); j=1; while(1) { system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^蜜餞^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=mijianRead(); while(a!=j) { head=head->next; j++; } printf("\t商品名:%s\n\t價(jià)格:%d\n\t規(guī)格:%s\n\t庫存:%d\n\t銷量:%d\n",head->pinming,head->jiage,head->guige,head->kucun,head->xiaoliang); printf("\n\n\t1.加入購物車\t2.立即購買\n\n\t3.返回\t\t4.退出\n\n\t請(qǐng)輸入您的操作:"); scanf("%d",&i); switch(i) { case1:gouwuche(p,head->pinming);break; case2:goumai5(p,head);break; case3:rp(p); case4:exit(0); default: break; } break; }}voidtg(YH*p){ TG*head; inti=1,j,a; system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^糖果^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=tangguoRead(); while(head!=NULL) { printf("\n\t%d.商品名:%-40s\t價(jià)格:%-10d",i,head->pinming,head->jiage); i++; head=head->next; } printf("\n\n\t請(qǐng)輸入您的選項(xiàng):"); scanf("%d",&a); j=1; while(1) { system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^糖果^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); head=tangguoRead(); while(a!=j) { head=head->next; j++; } printf("\t商品名:%s\n\t價(jià)格:%d\n\t規(guī)格:%s\n\t庫存:%d\n\t銷量:%d\n",head->pinming,head->jiage,head->guige,head->kucun,head->xiaoliang); printf("\n\n\t1.加入購物車\t2.立即購買\n\n\t3.返回\t\t4.退出\n\n\t請(qǐng)輸入您的操作:"); scanf("%d",&i); switch(i) { case1:gouwuche(p,head->pinming);break; case2:goumai6(p,head);break; case3:rp(p); case4:exit(0); default: break; } break; }}//購買voidgoumai1(YH*p,RP*head){ RP*w=rupinRead(); RP*e=w; YH*a=yonghuRead(); YH*c=a; char*ar; intb=0; charpassword[20],m; inti=0; while(strcmp(a->name,p->name)) { a=a->next; } ar=head->pinming; chuandisp(p,ar); printf("\t請(qǐng)輸入支付密碼:"); password[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { password[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { password[i++]=m; printf("*"); } } password[i]='\0'; if(strcmp(password,a->zhifu)==0) { b=a->money-head->jiage; if(b<0) { system("cls"); printf("\n\n\t您的余額不足\n\n\t請(qǐng)充值"); _getch(); yhchongzhi(p); } else { system("cls"); a->money=b; yonghuWrite(c); printf("\n\n\t支付成功!\n\n\t您的余額為%d\n\n",a->money); while(strcmp(w->pinming,head->pinming)) { w=w->next; } w->kucun=w->kucun-1; w->xiaoliang=w->xiaoliang+1; rupinWrite(e); _getch(); erjicaidan(p); } } else { system("cls"); printf("\n\n\t您輸入的密碼錯(cuò)誤\n\n\t任意鍵返回"); _getch(); erjicaidan(p); }}voidgoumai2(YH*p,JS*head){ JS*w=jiushuiRead(); JS*e=w; YH*a=yonghuRead(); YH*c=a; char*ar; intb=0; charpassword[20],m; inti=0; while(strcmp(a->name,p->name)) { a=a->next; } ar=head->pinming; chuandisp(p,ar); printf("\t請(qǐng)輸入支付密碼:"); password[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { password[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { password[i++]=m; printf("*"); } } password[i]='\0'; if(strcmp(password,a->zhifu)==0) { b=a->money-head->jiage; if(b<0) { system("cls"); printf("\n\n\t您的余額不足\n\n\t請(qǐng)充值"); _getch(); yhchongzhi(p); } else { system("cls"); a->money=b; yonghuWrite(c); printf("\n\n\t支付成功!\n\n\t您的余額為%d\n\n",a->money); while(strcmp(w->pinming,head->pinming)) { w=w->next; } w->kucun=w->kucun-1; w->xiaoliang=w->xiaoliang+1; jiushuiWrite(e); _getch(); erjicaidan(p); } } else { system("cls"); printf("\n\n\t您輸入的密碼錯(cuò)誤\n\n\t任意鍵返回"); _getch(); erjicaidan(p); }}voidgoumai3(YH*p,JG*head){ JG*w=jianguoRead(); JG*e=w; YH*a=yonghuRead(); YH*c=a; char*ar; intb=0; charpassword[20],m; inti=0; while(strcmp(a->name,p->name)) { a=a->next; } ar=head->pinming; chuandisp(p,ar); printf("\t請(qǐng)輸入支付密碼:"); password[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { password[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { password[i++]=m; printf("*"); } } password[i]='\0'; if(strcmp(password,a->zhifu)==0) { b=a->money-head->jiage; if(b<0) { system("cls"); printf("\n\n\t您的余額不足\n\n\t請(qǐng)充值"); _getch(); yhchongzhi(p); } else { system("cls"); a->money=b; yonghuWrite(c); printf("\n\n\t支付成功!\n\n\t您的余額為%d\n\n",a->money); while(strcmp(w->pinming,head->pinming)) { w=w->next; } w->kucun=w->kucun-1; w->xiaoliang=w->xiaoliang+1; jianguoWrite(e); _getch(); erjicaidan(p); } } else { system("cls"); printf("\n\n\t您輸入的密碼錯(cuò)誤\n\n\t任意鍵返回"); _getch(); erjicaidan(p); }}voidgoumai4(YH*p,GD*head){ GD*w=gaodianRead(); GD*e=w; YH*a=yonghuRead(); YH*c=a; char*ar; intb=0; charpassword[20],m; inti=0; while(strcmp(a->name,p->name)) { a=a->next; } ar=head->pinming; chuandisp(p,ar); printf("\t請(qǐng)輸入支付密碼:"); password[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { password[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { password[i++]=m; printf("*"); } } password[i]='\0'; if(strcmp(password,a->zhifu)==0) { b=a->money-head->jiage; if(b<0) { system("cls"); printf("\n\n\t您的余額不足\n\n\t請(qǐng)充值"); _getch(); yhchongzhi(p); } else { system("cls"); a->money=b; yonghuWrite(c); printf("\n\n\t支付成功!\n\n\t您的余額為%d\n\n",a->money); while(strcmp(w->pinming,head->pinming)) { w=w->next; } w->kucun=w->kucun-1; w->xiaoliang=w->xiaoliang+1; gaodianWrite(e); _getch(); erjicaidan(p); } } else { system("cls"); printf("\n\n\t您輸入的密碼錯(cuò)誤\n\n\t任意鍵返回"); _getch(); erjicaidan(p); }}voidgoumai5(YH*p,MJ*head){ MJ*w=mijianRead(); MJ*e=w; YH*a=yonghuRead(); YH*c=a; char*ar; intb=0; charpassword[20],m; inti=0; while(strcmp(a->name,p->name)) { a=a->next; } ar=head->pinming; chuandisp(p,ar); printf("\t請(qǐng)輸入支付密碼:"); password[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { password[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { password[i++]=m; printf("*"); } } password[i]='\0'; if(strcmp(password,a->zhifu)==0) { b=a->money-head->jiage; if(b<0) { system("cls"); printf("\n\n\t您的余額不足\n\n\t請(qǐng)充值"); _getch(); yhchongzhi(p); } else { system("cls"); a->money=b; yonghuWrite(c); printf("\n\n\t支付成功!\n\n\t您的余額為%d\n\n",a->money); while(strcmp(w->pinming,head->pinming)) { w=w->next; } w->kucun=w->kucun-1; w->xiaoliang=w->xiaoliang+1; mijianWrite(e); _getch(); erjicaidan(p); } } else { system("cls"); printf("\n\n\t您輸入的密碼錯(cuò)誤\n\n\t任意鍵返回"); _getch(); erjicaidan(p); }}voidgoumai6(YH*p,TG*head){ TG*w=tangguoRead(); TG*e=w; YH*a=yonghuRead(); YH*c=a; char*ar; intb=0; charpassword[20],m; inti=0; while(strcmp(a->name,p->name)) { a=a->next; } ar=head->pinming; chuandisp(p,ar); printf("\t請(qǐng)輸入支付密碼:"); password[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { password[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { password[i++]=m; printf("*"); } } password[i]='\0'; if(strcmp(password,a->zhifu)==0) { b=a->money-head->jiage; if(b<0) { system("cls"); printf("\n\n\t您的余額不足\n\n\t請(qǐng)充值"); _getch(); yhchongzhi(p); } else { system("cls"); a->money=b; yonghuWrite(c); printf("\n\n\t支付成功!\n\n\t您的余額為%d\n\n",a->money); while(strcmp(w->pinming,head->pinming)) { w=w->next; } w->kucun=w->kucun-1; w->xiaoliang=w->xiaoliang+1; tangguoWrite(e); _getch(); erjicaidan(p); } } else { system("cls"); printf("\n\n\t您輸入的密碼錯(cuò)誤\n\n\t任意鍵返回"); _getch(); erjicaidan(p); }}//用戶注冊(cè)// <<<<---用戶--->>>>voidzhuce(){ YHa; inti=0,d; charb[20],c[20],e[20],m; YH*py,*head,*p1; head=yonghuRead(); p1=head; py=p1; while(p1->next!=NULL) { p1=p1->next; } system("cls"); printf("\t\t‖^^^^^^^^^^^^^^^^^^用戶注冊(cè)^^^^^^^^^^^^^^^^^^‖\n\n"); printf("\t請(qǐng)輸入用戶名:\t"); scanf("%s",); printf("\n\n"); while(py!=NULL) { if(strcmp(py->name,)==0) { printf("\t您注冊(cè)的用戶已存在\n\n\t請(qǐng)重新輸入用戶名\n\n\t按任意鍵返回"); _getch(); zhuce(); } py=py->next; } printf("\t請(qǐng)輸入密碼:\t"); a.mima[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { a.mima[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { a.mima[i++]=m; printf("*"); } } a.mima[i]='\0'; printf("\n\n"); printf("\t請(qǐng)確認(rèn)密碼:\t"); i=0; b[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { b[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { b[i++]=m; printf("*"); } } b[i]='\0'; printf("\n\n"); if(strcmp(a.mima,b)!=0) { printf("\t您輸入的密碼有誤\n\n\t請(qǐng)從新輸入!"); _getch(); zhuce(); } printf("\t請(qǐng)輸入支付密碼:\t"); i=0; a.zhifu[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { a.zhifu[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { a.zhifu[i++]=m; printf("*"); } } a.zhifu[i]='\0'; printf("\n\n"); printf("\t請(qǐng)輸入手機(jī)號(hào)\t"); scanf("%s",a.mibao); //驗(yàn)證碼 srand((unsignedint)time(NULL)); d=rand()%9000+1000; sprintf(c,"%d",d); printf("\t驗(yàn)證碼為:\t%s\n\n",c); printf("\t請(qǐng)輸入驗(yàn)證碼:\t"); scanf("%s",e); a.money=0; a.next=NULL; if(strcmp(c,e)==0) { system("cls"); a.next=NULL; p1->next=&a; yonghuWrite(head); printf("\t注冊(cè)成功!\n\n\t按任意鍵返回"); _getch(); denglu(); } else { system("cls"); printf("\t驗(yàn)證碼錯(cuò)誤\n\n\t按任意鍵返回"); _getch(); zhuce(); }}//忘記密碼voidwangjimima(){ system("cls"); YH*p; p=yonghuRead(); chara[20],b[20],c[20],e[20]; intd,f; YH*head=NULL; head->next=NULL; head=yonghuRead(); system("cls"); printf("\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^忘記密碼^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n\n"); printf("\t\t請(qǐng)輸入用戶名:\t"); scanf("%s",a); printf("\n\n"); //密保 printf("\t\t手機(jī)號(hào):\t"); scanf("%s",b); printf("\n\n"); //驗(yàn)證碼 srand((unsignedint)time(NULL)); d=rand()%9000+1000; sprintf(c,"%d",d); printf("\t\t驗(yàn)證碼為:\t%s\n\n",c); printf("\t\t請(qǐng)輸入驗(yàn)證碼:\t"); scanf("%s",e); //判斷信息是否注冊(cè)在文件中 p=head; while(p!=NULL) { if(strcmp(p->name,a)==0) { if(strcmp(p->mibao,b)==0) { if(strcmp(c,e)==0) { xiugaimima(p);break; } } } p=p->next; } //用戶名錯(cuò)誤 system("cls"); printf("\n\n▂▃▄▅▆▇█歡迎進(jìn)入『百味小屋』█▇▆▅▄▃▂\n\n\n\n"); printf("\t\t┌----------------------------------┐\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t您輸入的用戶名或密碼錯(cuò)誤‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t1.重新輸入‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t2.忘記密碼‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t3.注冊(cè)用戶‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t‖\t4.退出‖\n"); printf("\t\t‖\t\t\t\t‖\n"); printf("\t\t└----------------------------------┘\n\n\t\t"); f=_getch(); if(f==50)//2 { wangjimima(); } elseif(f==51) { zhuce(); } elseif(f==52) { exit(0); } else{ system("cls"); maijia(); }}//密碼修改voidxiugaimima(YH*a){ YH*p,*head; inti; charm; p=yonghuRead(); head=p; system("cls"); printf("\t‖^^^^^^^^^^^^^^^^^^^^^^^^修改密碼^^^^^^^^^^^^^^^^^^^^^^^^‖\n\n"); while(p!=NULL) { if(a->name==p->name) { printf("\n\n\n\t輸入您要修改的密碼:\t"); i=0; printf("請(qǐng)輸入密碼:"); p->mima[0]='\0'; while((m=_getch())!=13&&i<20)//13為回車 { if(m==8&&i>0)//8為退格 { p->mima[i--]='\0';//刪除最后一個(gè),并且計(jì)數(shù)器減1 printf("\b\b"); } else { p->mima[i++]=m; printf("*"); } } p->mima[i]='\0'; } p=p->next; } yonghuWrite(head); printf("\t修改成功\n\n\t任意鍵返回"); _getch(); denglu();}//用戶充值voidyhchongzhi(YH*head){ doublemm; doubleresult; inta=0; YH*pm,*p,*hea; charb; p=yonghuRead(); hea=p; pm=head; system("cls"); mm=6323429342342; printf("\t您的銀行卡號(hào)是:%19.0d",mm); srand((unsignedint)time(NULL)); result=rand()%9000000+10000000; mm=mm+result; printf("\n\n\t請(qǐng)輸入充值的金額:\t"); scanf("%d",&a); while(p!=NULL) { if(strcmp(p->name,pm->name)==0) { p->money=p->money+a;break; } p=p->next; } yonghuWrite(hea); printf("\n\n\t\t充值成功!\n\t\t您的余額為:%d\n\t\t是否繼續(xù)充值(Y/N)\t\t",p->money); b=_getch(); if(b=='Y') { yhchongzhi(p); } else { erjicaidan(head); }}//買家購買的商品傳遞給商家voidchuandisp(YH*p1,char*ar){ RP*a; JS*b; JG*c; GD*d; MJ*e; TG*f; CD*p; chardz[100],dh[20]; //p->next=NULL; a=rupinRead(); b=jiushuiRead(); c=jianguoRead(); d=gaodianRead(); e=mijianRead(); f=tangguoRead(); p=cdRead(); system("cls"); while(a!=NULL) { if(strcmp(ar,a->pinming)==0) { FILE*fp=fopen("chuandi.txt","a+"); strcpy(p->pinming,a->pinming); p->jiage=a->jiage; strcpy(p->guige,a->guige); printf("\t請(qǐng)輸入送貨地址:"); scanf("%s",dz); strcpy(p->zhuzhi,dz); printf("\n\n\t請(qǐng)輸入您的聯(lián)系電話:"); scanf("%s",dh); strcpy(p->dianhua,dh); if(fp==NULL) { printf("打開文件失??!"); _getch();//按任意鍵退出 } fprintf(fp,"%s%d%s%s%s\n",p->pinming,p->jiage,p->guige,p->zhuzhi,p->dianhua); fclose(fp); system("cls"); printf("\n\n\t購買成功!\n\n\t任意鍵返回"); _getch(); erjicaidan(p1); } a=a->next; } while(b!=NULL) { if(strcmp(ar,b->pinming)==0) { FILE*fp=fopen("chuandi.txt","a+"); strcpy(p->pinming,b->pinming); p->jiage=b->jiage; strcpy(p->guige,b->guige); printf("\t請(qǐng)輸入送貨地址:"); scanf("%s",dz); strcpy(p->zhuzhi,dz); printf("\n\n\t請(qǐng)輸入您的聯(lián)系電話:"); scanf("%s",dh); strcpy(p->dianhua,dh); if(fp==NULL) { printf("打開文件失?。?); _getch();//按任意鍵退出 } fprintf(fp,"%s%d%s%s%s\n",p->pinming,p->jiage,p->guige,p->zhuzhi,p->dianhua); fclose(fp); system("cls"); printf("\n\n\t購買成功!\n\n\t任意鍵返回"); _getch(); erjicaidan(p1); } b=b->next; } while(c!=NULL) { if(strcmp(ar,c->pinming)==0) { FILE*fp=fopen("chuandi.txt","a+"); strcpy(p->pinming,c->pinming); p->jiage=c->jiage; strcpy(p->guige,c->guige); printf("\t請(qǐng)輸入送貨地址:"); scanf("%s",dz); strcpy(p->zhuzhi,dz); printf("\n\n\t請(qǐng)輸入您的聯(lián)系電話:"); scanf("%s",dh); strcpy(p->dianhua,dh); if(fp==NULL) { printf("打開文件失??!"); _getch();//按任意鍵退出 } fprintf(fp,"%s%d%s%s%s\n",p->pinming,p->jiage,p->guige,p->zhuzhi,p->dianhua); fclose(fp); system("cls"); printf("\n\n\t購買成功!\n\n\t任意鍵返回"); _getch(); erjicaidan(p1); } c=c->next; } while(d!=NULL) { if(strcmp(ar,

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論