您好,欢迎访问三七文档
#includeiostream#includetime.husingnamespacestd;structpai{intpaifu;inthuase;intyanse;intdianshu;intleixing;intchangdu;voidKanpai(){if(paifu==0||paifu==1);elseprintf(牌副参数错误!\n);switch(huase){case0:cout黑桃;break;case1:cout红桃;break;case2:cout草花;break;case3:cout方片;break;case-1:cout无色;break;default:printf(花色错误!\n);break;}switch(dianshu){case0:coutA;break;case1:cout2;break;case2:cout3;break;case3:cout4;break;case4:cout5;break;case5:cout6;break;case6:cout7;break;case7:cout8;break;case8:cout9;break;case9:cout10;break;case10:coutJ;break;case11:coutQ;break;case12:coutK;break;case-1:cout无点数;break;default:printf(点数错误!\n);break;}switch(leixing){case101:cout【杀】endl;break;case102:cout【闪】endl;break;case103:cout【桃】endl;break;case201:cout【过河拆桥】endl;break;case202:cout【顺手牵羊】endl;break;case203:cout【无中生有】endl;break;case204:cout【决斗】endl;break;case205:cout【借刀杀人】endl;break;case206:cout【桃园结义】endl;break;case207:cout【五谷丰登】endl;break;case208:cout【南蛮入侵】endl;break;case209:cout【万箭齐发】endl;break;case210:cout【无懈可击】endl;break;case251:cout【乐不思蜀】endl;break;case252:cout【闪电】endl;break;case301:cout【诸葛连弩(1)】endl;break;case302:cout【雌雄双股剑(2)】endl;break;case303:cout【青釭剑(2)】endl;break;case304:cout【青龙偃月刀(3)】endl;break;case305:cout【丈八蛇矛(3)】endl;break;case306:cout【贯石斧(3)】endl;break;case307:cout【方天画戟(4)】endl;break;case308:cout【麒麟弓(5)】endl;break;case331:cout【八卦阵】endl;break;case361:cout【赤兔(-1)】endl;break;case362:cout【大宛(-1)】endl;break;case363:cout【紫辛(-1)】endl;break;case381:cout【爪黄飞电(+1)】endl;break;case382:cout【的卢(+1)】endl;break;case383:cout【绝影(+1)】endl;break;default:printf(类型参数错误!);break;}}};voidQishixipai(paiA[2][4][13],paipaidui[104]){inti,m,x,y,z,a[104]={0};srand((unsigned)time(NULL));for(i=1;i=104;i++){while(a[m=rand()%104]);a[m]=i;}for(i=0;i=103;i++){x=(a[i]-1)/52;y=((a[i]-1)-52*x)/13;z=(a[i]-1)%13;paidui[i]=A[x][y][z];}}voidXipai(paipaidui[104],int*paiduishu,paiqipaidui[104],int*qipaishu){inti,m,a[104]={0};srand((unsigned)time(NULL));for(i=1;i=(*qipaishu);i++){while(a[m=rand()%(*qipaishu)]);a[m]=i;}for(i=0;i=((*qipaishu)-1);i++){paidui[i]=qipaidui[a[i]];qipaidui[a[i]].leixing=-1;(*paiduishu)++;(*qipaishu)--;}for(i=(*paiduishu);i=103;i++)paidui[i].leixing=-1;}paiMo1pai(paiA[104],int*x,paiB[104],int*y,int*b){paip;if((*x)==0)Xipai(A,x,B,y);elseif((*x)0)printf(摸牌参数错误!);else;p=A[104-(*x)];(*x)--;(*b)++;return(p);}structwujiang{charname;inttili;inttilishangxian;intshoupaishangxian;inthuihekaishi;intpanding;intmopai;intchupai;intqipai;inthuihejieshu;intjuese;paishoupai[20];intshoupaishu;paizhuangbei[4];intzhuangbeishu;paipandingpai[3];intpandingshu;intjuli[1];voidKanshoupai(){printf(玩家当前手牌:\n);if(shoupaishu){intm;for(m=0;m=(shoupaishu-1);m++){printf(%d,m);(shoupai[m]).Kanpai();}}elseprintf(空城!\n);printf(\n);}voidKanzhuangbei(){if(juese)printf(玩家);elseprintf(电脑);printf(当前装备:\n);printf(0武器:);if((zhuangbei[0]).leixing==-1)printf(空\n);else(zhuangbei[0]).Kanpai();printf(1防具:);if((zhuangbei[1]).leixing==-1)printf(空\n);else(zhuangbei[1]).Kanpai();printf(2进攻马:);if((zhuangbei[2]).leixing==-1)printf(空\n);else(zhuangbei[2]).Kanpai();printf(3防御马:);if((zhuangbei[3]).leixing==-1)printf(空\n);else(zhuangbei[3]).Kanpai();printf(\n);}voidKanpandingpai(){if(juese)printf(玩家);elseprintf(电脑);printf(当前判定区:\n);if((pandingpai[0]).leixing==-1)printf(空\n);else{printf(0);(pandingpai[0]).Kanpai();if((pandingpai[1]).leixing==-1);else{printf(1);(pandingpai[1]).Kanpai();if((pandingpai[2]).leixing==-1);else{printf(2);(pandingpai[2]).Kanpai();}}}}};voidMopai(int*shoupaishu,paishoupai[20],paiA[104],int*x,paiB[104],int*y,intjuese){if(juese)printf(玩家从牌堆摸2张牌\n);elseprintf(电脑从牌堆摸2张牌\n);paip;p=Mo1pai(A,x,B,y,shoupaishu);shoupai[*shoupaishu-1]=p;paiq;q=Mo1pai(A,x,B,y,shoupaishu);shoupai[*shoupaishu-1]=q;intm;if(juese){printf(玩家当前手牌:\n);for(m=0;m=(*shoupaishu-1);m++){printf(%d,m);(shoupai[m]).Kanpai();}}printf(牌堆还剩%d张牌!\n\n,*x);}voidQishishoupai(wujiang*w,paiA[104],int*x,paiB[104],int*y){paia;a=Mo1pai(A,x,B,y,&((*w).shoupaishu));(*w).shoupai[(*w).shoupaishu-1]=a;paib;b=Mo1pai(A,x,B,y,&((*w).shoupaishu));(*w).shoupai[(*w).shoupaishu-1]=b;paic;c=Mo1pai(A,x,B,y,&((*w).shoupaishu));(*w).shoupai[(*w).shoupaishu-1]=c;paid;d=Mo1pai(A,x,B,y,&((*w).shoupaishu));(*w).shoupai[(*w).shoupaishu-1]=d;intm;if((*w).juese)printf(玩家从牌堆摸4张牌\n);elseprintf(电脑从牌堆摸4张牌\n);if((*w).juese){printf(玩家当前手牌:\n);for(m=0;m=((*w).shoupaishu-1);m++){printf(%d,m);((*w).shoupai[m]).Kanpai();}}printf(牌堆还剩%d张牌!\n\n,*x);}voidPanding(paipaidui[104],int*paiduishu,paiqipaidui[104],int*qipaishu){paidui[*paiduishu].Kanpai();qipaidui[*qipaishu]=paidui[*paiduishu];(*paiduishu)--;(*qipaishu)++;}paiZhangba(wujiang*w,paiqipaidui[104],int*qipaishu){intx,y;paip;for(;;){inti,j;printf(请输入任意两张手牌之前的编号,以空格隔开,以回车结束!\n);scanf(%d,&x);scanf(%d,&y);if((x=0)&&(x(*w).shoupaishu)&&(y=0)&&(y(*w).shoupaishu-1)){switch((((*w).shoupai[x].huase)%2)+(((*w).shoupai[y].huase)%2)){case0:p.yanse=0;break;
本文标题:三国杀C++程序
链接地址:https://www.777doc.com/doc-6015421 .html