52张牌随机分给4个玩家,要求每个玩家的牌用一个一维数组表示。
我们采用模拟大法。初始化一副扑克牌,洗牌,发牌。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication43
{
class Program
{
enum Suit
{
Spade, Heart, Diamond, Club
}
enum Value
{
Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queue, King, Ace
}
class Card
{
public Suit suit;
public Value value;
}
static void Main(string[] args)
{
Card[] c = new Card[52];
for(int i=0;i=0; k--) //洗牌
{
Random rand = new Random();
int p = rand.Next(k);
Card temp=new Card ();
temp = c[p];
c[p] = c[k];
c[k] = temp;
}
Card[] E = new Card[13]; Card[] W = new Card[13];
Card[] S = new Card[13]; Card[] N = new Card[13];
int A=0,B=0,C=0,D=0;
for(int j=0;j |