有54张牌,存到一个cards数组中去,为了将这些牌设置其值为0~53,要求:用随机算法,将这些牌在数组中的顺序打乱
int[] cards = new int[54];
for (int i = 0; i < cards.Length; i++)
{
cards[i] = i;
}
Random rnd = new Random();
for (int i = 53; i >= 0; i--)
{
int j = rnd.Next(i);
int temp;
temp = cards[j];
cards[j] = cards[i];
cards[i] = temp;
}
//建立三个17张牌的数组
int[] play1 = new int[17];
int[] play2 = new int[17];
int[] play3 = new int[17];
for(int i=0;i<54;i++)
牌的顺序已打乱了,接下来怎么写呀?头好晕
慕婉清0_郁乱我心
相关分类