不知道如何使这个甲板洗牌 [英] Not sure how to make this deck shuffle

查看:107
本文介绍了不知道如何使这个甲板洗牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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();
  }
}

我一直在试图让过去这个小时洗牌的甲板没有,没有运气。我劈成两半的甲板和将要洗牌数组数它慢腾腾倍量,然后打印出数组其被打乱了。我不知道在所有实际如何添加第三排,将打乱他们所有。但是,如果有人知道,如果你能介意告诉我那简直太好了。

I have been trying to make this deck shuffle for the past hour no with no luck. I split the deck in half and was going to shuffle the array count the amount of times it shuffles and then print out the array after its been shuffled. I'm not sure at all actually how to add the third array that would shuffle them all. But if anyone knows if you could mind telling me that'd be great.

推荐答案

我不知道为什么你劈成两半的甲板上,但如果你不需要,那么你可以使用 Col​​lections.shuffle( )

I am not sure why you split the deck in half, but if you dont need to, then you could use 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));

这篇关于不知道如何使这个甲板洗牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆