预览加载中,请您耐心等待几秒...
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

publicpartialclassForm1:Form{publicinta;publicintb;publicinti;publicint[]ab=newint[12];//数组ab存放临时的牌的图片号publicintzhuangnumber;//用于存放庄家点数publicintgamernumber;//用于存放游戏者点数publicPictureBox[]ptb=newPictureBox[12];publicForm1(){InitializeComponent();}//生成牌与点数privatevoidFirst(outinta,outintb,intq){Randomrd=newRandom();a=rd.Next(0,51);if(a>=0&&a<=3){b=2;}elseif(a>=4&&a<=7){b=3;}elseif(a>=8&&a<=11){b=4;}elseif(a>=12&&a<=15){b=5;}elseif(a>=16&&a<=19){b=6;}elseif(a>=20&&a<=23){b=7;}elseif(a>=24&&a<=27){b=8;}elseif(a>=28&&a<=31){b=9;}elseif(a>=32&&a<=47){b=10;}elseif(a>=48&&a<=51){if(q>=0&&q<=21){b=10;}elseb=1;}else{b=0;Console.Read();}}//用递归算法随即生成之前未出现的牌publicvoidBijiao(outinta,outintb,intq,int[]abc){inti;Randomrd=newRandom();a=rd.Next(0,51);if(a>=0&&a<=3){b=2;}elseif(a>=4&&a<=7){b=3;}elseif(a>=8&&a<=11){b=4;}elseif(a>=12&&a<=15){b=5;}elseif(a>=16&&a<=19){b=6;}elseif(a>=20&&a<=23){b=7;}elseif(a>=24&&a<=27){b=8;}elseif(a>=28&&a<=31){b=9;}elseif(a>=32&&a<=47){b=10;}elseif(a>=48&&a<=51){if(q>=0&&q<=21){b=10;}elseb=1;}else{b=0;Console.Read();}for(i=0;i<52;i++){if(abc[i]==a)Bijiao(outa,outb,q,abc);elsebreak;}}//不要牌后比较出赢家并把庄家隐藏的牌显现privatevoidbuttonResult_Click(objectsender,EventArgse){if(zhuangnumber>gamernumber){for(i=1;i<6;i++){if(ab[i]!=100)this.ptb[i].Image=this.imageList1.Images[ab[i]];}this.label2.Text=zhuangnumber.ToString();MessageBox.Show("庄家赢了!开始下一局!");}elseif(zhuangnumber==gamernumber){for(i=1;i<6;i++){if(ab[i]!=100)this.ptb[i].Image=this.imageList1.Images[ab[i]];}this.label2.Text=zhuangnumber.ToString();MessageBox.Show("庄家赢了!开始下一局!");}else{for(i=1;i<6;i++){if(ab[i]!=100)this.ptb[i].Image=this.imageList1.Images[ab[i]];}this.label2.Text=zhuangnumber.ToString();MessageBox.Show("你赢了!开始下一局!");}}privatevoid结束ToolStripMenuItem_Click(objectsender,EventArgse){Application.Exit();}//游戏规则在第二个Form上privatevoid游戏规则ToolStripMenuItem_Click(objectsender,EventArgse){Form2myform=newForm2();myform.Show();}//开始在panel上添加PictureBox并设置其属性,生成四张牌,各两张(庄家有一张隐藏)privatevoid开始ToolStripMenuItem_Click_1(o