import java.util.*;
public class shuffleDeck
{
public static int shuffleDeck (int[] deck, int theNumber)
{
int [] deck2 = new int [26];
int [] deck3 = new int [26];
return theNumber;
}
public static void main(String[] args)
{
int [] deck = new int [52];
for(int i=0; i<52; i++)
{
deck[i]=i+1;
}
int count;
count=1;
int total=1;
shuffleDeck(deck, count);
System.out.println();
}
}
过去一小时我一直在尝试洗牌,但没有成功。我将这副牌分成两半,并打算对数组进行洗牌次数计数,然后在洗牌后打印出数组。我根本不确定如何添加第三个数组来对它们进行洗牌。但如果有人知道你能介意告诉我那就太好了。
最佳答案
我不知道为什么你把牌分成两半,但如果你不需要,那么你可以使用Collections.shuffle()
:
// Create an array, fill it the way you want
Integer[] deck = new Integer[]{1, 2, 3, 4};
// Shuffle the elements in the array
Collections.shuffle(Arrays.asList(deck));
关于java - 不知道如何洗牌,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30756226/