求一个21点小游戏C#的项目源码,有的发过来,谢谢各位大神了!
4个回答
展开全部
花了近1小时完成的(我这的vs2010有问题。。郁闷。。)
一定要采纳啊!
代码如下
-----------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication_21点游戏
{
class Program
{
static void Main(string[] args)
{
Start:
Console.Clear();
//初始化数组,将对应花色的各13张牌放入数组
for (int i = 0; i < zhuangjia.Length; i++)
{
zhuangjia[i] = null;
zhuangjia_point[i] = 0;
}
for (int i = 0; i < xianjia.Length; i++)
{
xianjia[i] = null;
xianjia_point[i] = 0;
}
zhuangjia_n = 0;
xianjia_n = 0;
for (int i = 0; i < 13; i++)
{
hongtao[i] = i++;
}
for (int i = 0; i < 13; i++)
{
fangkuai[i] = i++;
}
for (int i = 0; i < 13; i++)
{
meihua[i] = i++;
}
for (int i = 0; i < 13; i++)
{
heitao[i] = i++;
}
Console.WriteLine("初始发牌:");
for (int i = 0; i < 2; i++)
{
zhuangjia[i] = SendCard("zhuangjia");
}
Console.WriteLine("庄家:{0} {1}", "底牌", zhuangjia[1]);
for (int i = 0; i < 2; i++)
{
xianjia[i] = SendCard("xianjia");
}
Console.WriteLine("闲家:{0} {1}", xianjia[0],xianjia[1]);
Console.WriteLine("游戏开始!");
int number = 0;
for (int i = 2; i < 5; i++)
{
number++;
Console.WriteLine();
Console.WriteLine("第{0}轮开始!",number);
Console.Write("闲家是否要牌?<Y/N>");
string choose=Console.ReadLine();
switch (choose)
{
case "Y":
break;
case "N":
Console.WriteLine("闲家");
goto Next;
}
xianjia[i]=SendCard("xianjia");
Console.WriteLine("你得到了:{0}",xianjia[i]);
Console.Write("闲家:");
foreach (string item in xianjia)
{
Console.Write(item+" ");
}
Console.WriteLine();
int xianjia_zongfen = 0;
foreach (int item in xianjia_point)
{
xianjia_zongfen += item;
}
if (xianjia_zongfen>21)
{
Console.WriteLine("闲家的总分是:"+xianjia_zongfen.ToString());
Console.WriteLine("超过了21!爆牌!");
Console.WriteLine("闲家输了!庄家赢了!");
goto Endchoose;
}
Next:
zhuangjia[i] = SendCard("zhuangjia");
int zhuangjia_zongfen=0;
foreach (int item1 in zhuangjia_point)
{
zhuangjia_zongfen += item1;
}
if (zhuangjia_zongfen > 21)
{
zhuangjia[i] = null;
zhuangjia_point[i] = 0;
Console.WriteLine("庄家停牌!");
goto End;
}
else
{
Console.WriteLine("庄家得到了:"+zhuangjia[i]);
Console.Write("庄家:");
foreach (string item in zhuangjia)
{
Console.Write(item+" ");
}
Console.WriteLine();
}
}
End:
Console.WriteLine("游戏结束!");
Console.WriteLine("开始结算:");
int xianjiazongfen = 0;
foreach (int item in xianjia_point)
{
xianjiazongfen += item;
}
Console.WriteLine("玩家总分:{0}",xianjiazongfen);
int zhuangjiazongfen = 0;
foreach (int item in zhuangjia_point)
{
zhuangjiazongfen += item;
}
Console.WriteLine("庄家总分:"+zhuangjiazongfen);
if (xianjiazongfen>zhuangjiazongfen)
{
Console.WriteLine("闲家赢了!");
goto Endchoose;
}
if (xianjiazongfen<zhuangjiazongfen)
{
Console.WriteLine("庄家赢了!");
goto Endchoose;
}
if (xianjiazongfen==zhuangjiazongfen)
{
Console.WriteLine("平局!");
goto Endchoose;
}
Endchoose:
Console.Write("是否再来一局?<Y/N>");
string endchoose=Console.ReadLine();
switch (endchoose)
{
case "Y":
goto Start;
case "N":
break;
default:
goto Endchoose;
}
Console.ReadKey();
}
static string SendCard(string to)
{
string card=null;
Random r1 = new Random();
start:
int point=r1.Next(0,13);
switch(r1.Next(0,3))
{
case 0:
if (hongtao[point]==0)
{
goto start;
}
card = color[0]+hongtao[point].ToString();
hongtao[point] = 0;
break;
case 1:
if (fangkuai[point]==0)
{
goto start;
}
card = color[1]+fangkuai[point].ToString();
fangkuai[point] = 0;
break;
case 2:
if (heitao[point]==0)
{
goto start;
}
card = color[2]+heitao[point].ToString();
heitao[point] = 0;
break;
case 3:
if (meihua[point]==0)
{
goto start;
}
card = color[3] + meihua[point];
meihua[point] = 0;
break;
}
if (point == 11||point==12||point==13)
{
point = 10;
}
switch (to)
{
case "zhuangjia":
zhuangjia_point[zhuangjia_n] = point;
zhuangjia_n++;
break;
case "xianjia":
xianjia_point[xianjia_n] = point;
xianjia_n++;
break;
}
return card;
}
static int zhuangjia_n = 0;
static int xianjia_n = 0;
static string[] color = new string[4] { "红桃", "方块", "黑桃", "梅花" }; //声明变量,用于存放颜色
static int[] fangkuai = new int[13]; //声明数组,代表四个花色
static int[] hongtao = new int[13];
static int[] heitao = new int[13];
static int[] meihua = new int[13];
static string[] zhuangjia = new string[5];
static int[] zhuangjia_point = new int[5];
static string[] xianjia = new string[5];
static int[] xianjia_point = new int[5];
}
}
----------------------------------------------------------------------------------------------------------------
注释写的不怎么详细,A和JQK只能显示为1,11,12,13,因还有其他事情,请见谅!
最后说一句:这是我辛苦劳动的成果,一定要采纳啊!
一定要采纳啊!
代码如下
-----------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication_21点游戏
{
class Program
{
static void Main(string[] args)
{
Start:
Console.Clear();
//初始化数组,将对应花色的各13张牌放入数组
for (int i = 0; i < zhuangjia.Length; i++)
{
zhuangjia[i] = null;
zhuangjia_point[i] = 0;
}
for (int i = 0; i < xianjia.Length; i++)
{
xianjia[i] = null;
xianjia_point[i] = 0;
}
zhuangjia_n = 0;
xianjia_n = 0;
for (int i = 0; i < 13; i++)
{
hongtao[i] = i++;
}
for (int i = 0; i < 13; i++)
{
fangkuai[i] = i++;
}
for (int i = 0; i < 13; i++)
{
meihua[i] = i++;
}
for (int i = 0; i < 13; i++)
{
heitao[i] = i++;
}
Console.WriteLine("初始发牌:");
for (int i = 0; i < 2; i++)
{
zhuangjia[i] = SendCard("zhuangjia");
}
Console.WriteLine("庄家:{0} {1}", "底牌", zhuangjia[1]);
for (int i = 0; i < 2; i++)
{
xianjia[i] = SendCard("xianjia");
}
Console.WriteLine("闲家:{0} {1}", xianjia[0],xianjia[1]);
Console.WriteLine("游戏开始!");
int number = 0;
for (int i = 2; i < 5; i++)
{
number++;
Console.WriteLine();
Console.WriteLine("第{0}轮开始!",number);
Console.Write("闲家是否要牌?<Y/N>");
string choose=Console.ReadLine();
switch (choose)
{
case "Y":
break;
case "N":
Console.WriteLine("闲家");
goto Next;
}
xianjia[i]=SendCard("xianjia");
Console.WriteLine("你得到了:{0}",xianjia[i]);
Console.Write("闲家:");
foreach (string item in xianjia)
{
Console.Write(item+" ");
}
Console.WriteLine();
int xianjia_zongfen = 0;
foreach (int item in xianjia_point)
{
xianjia_zongfen += item;
}
if (xianjia_zongfen>21)
{
Console.WriteLine("闲家的总分是:"+xianjia_zongfen.ToString());
Console.WriteLine("超过了21!爆牌!");
Console.WriteLine("闲家输了!庄家赢了!");
goto Endchoose;
}
Next:
zhuangjia[i] = SendCard("zhuangjia");
int zhuangjia_zongfen=0;
foreach (int item1 in zhuangjia_point)
{
zhuangjia_zongfen += item1;
}
if (zhuangjia_zongfen > 21)
{
zhuangjia[i] = null;
zhuangjia_point[i] = 0;
Console.WriteLine("庄家停牌!");
goto End;
}
else
{
Console.WriteLine("庄家得到了:"+zhuangjia[i]);
Console.Write("庄家:");
foreach (string item in zhuangjia)
{
Console.Write(item+" ");
}
Console.WriteLine();
}
}
End:
Console.WriteLine("游戏结束!");
Console.WriteLine("开始结算:");
int xianjiazongfen = 0;
foreach (int item in xianjia_point)
{
xianjiazongfen += item;
}
Console.WriteLine("玩家总分:{0}",xianjiazongfen);
int zhuangjiazongfen = 0;
foreach (int item in zhuangjia_point)
{
zhuangjiazongfen += item;
}
Console.WriteLine("庄家总分:"+zhuangjiazongfen);
if (xianjiazongfen>zhuangjiazongfen)
{
Console.WriteLine("闲家赢了!");
goto Endchoose;
}
if (xianjiazongfen<zhuangjiazongfen)
{
Console.WriteLine("庄家赢了!");
goto Endchoose;
}
if (xianjiazongfen==zhuangjiazongfen)
{
Console.WriteLine("平局!");
goto Endchoose;
}
Endchoose:
Console.Write("是否再来一局?<Y/N>");
string endchoose=Console.ReadLine();
switch (endchoose)
{
case "Y":
goto Start;
case "N":
break;
default:
goto Endchoose;
}
Console.ReadKey();
}
static string SendCard(string to)
{
string card=null;
Random r1 = new Random();
start:
int point=r1.Next(0,13);
switch(r1.Next(0,3))
{
case 0:
if (hongtao[point]==0)
{
goto start;
}
card = color[0]+hongtao[point].ToString();
hongtao[point] = 0;
break;
case 1:
if (fangkuai[point]==0)
{
goto start;
}
card = color[1]+fangkuai[point].ToString();
fangkuai[point] = 0;
break;
case 2:
if (heitao[point]==0)
{
goto start;
}
card = color[2]+heitao[point].ToString();
heitao[point] = 0;
break;
case 3:
if (meihua[point]==0)
{
goto start;
}
card = color[3] + meihua[point];
meihua[point] = 0;
break;
}
if (point == 11||point==12||point==13)
{
point = 10;
}
switch (to)
{
case "zhuangjia":
zhuangjia_point[zhuangjia_n] = point;
zhuangjia_n++;
break;
case "xianjia":
xianjia_point[xianjia_n] = point;
xianjia_n++;
break;
}
return card;
}
static int zhuangjia_n = 0;
static int xianjia_n = 0;
static string[] color = new string[4] { "红桃", "方块", "黑桃", "梅花" }; //声明变量,用于存放颜色
static int[] fangkuai = new int[13]; //声明数组,代表四个花色
static int[] hongtao = new int[13];
static int[] heitao = new int[13];
static int[] meihua = new int[13];
static string[] zhuangjia = new string[5];
static int[] zhuangjia_point = new int[5];
static string[] xianjia = new string[5];
static int[] xianjia_point = new int[5];
}
}
----------------------------------------------------------------------------------------------------------------
注释写的不怎么详细,A和JQK只能显示为1,11,12,13,因还有其他事情,请见谅!
最后说一句:这是我辛苦劳动的成果,一定要采纳啊!
更多追问追答
追问
感谢大神
能帮我再完善点吗
展开全部
简单例子,可以适当加入自己的元素。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你百度搜【51aspx】
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2020-04-16
展开全部
薄膜电容器是将聚乙酯,聚丙烯,聚苯乙烯或聚碳酸酯等塑料薄膜,从两端重叠后,卷绕成圆筒状的电容器。其结构和纸介电容相同,介质是涤纶或者聚苯乙烯等。涤纶薄膜电容,介电常数较高,体积小,容量大,稳定性比较好,适宜做旁路电容。聚苯乙烯薄膜电容,介质损耗小,绝缘电阻高,但是温度系数大,可用于高频电路。 音箱的高频单元为提高高频性能,其音圈和振动部分会设计得很轻巧,对低频信号的响应很低,馈入频率过低的功率信号很容易引起振动部件损坏、音圈烧毁。因此多分频的音箱都会使用分频器,让各种频率成分的信号、各频段单元发挥出应有的作用。 在中高音单元上加的薄膜电容,实质是一个简易的分频器,薄膜电容起到阻碍低频、只允许高频通过的“高通滤波器”的作用。薄膜电容容量越小则分频点越高、过滤低频成分的作用越明显。 采用这种简易分频器的一般都是两分频音箱,它的中低频单元馈入的是全频段信号(但中低频单元对高频的响应也很低,因此并不会播放出太多的高频声音)、高频单元馈入的是经高通滤波的高频信号。因过滤掉了一部分成分的信号,加了分频器的喇叭在听感上会比馈入全频段信号时声音小,因此也就造成了音响加了音频薄膜电容后声音小了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询