大家告诉我洗54张扑克牌的程序实现思路好吗?

解决方案 »

  1.   

    再开54张牌的内存后,随机从原来0-53中随机取一张放到第一,把那张从原来的数组中减掉,然后再从0-52中随机取,放到第二…………建议用vector
      

  2.   

    好像是我们单位以前的考题嘛。
    这有个java的:
            //================shuffle=====================//
            byte[] temp = new byte[52];
            for (byte i = 0; i < 52; i++) {
                temp[i] = i;
            }
            byte count = 52;
            Random rm = new Random();
            byte index;
            for (byte i = 0; i < 52; i++) {
                index = (byte) (Math.abs(rm.nextInt()) % count);
                unDistributeCards.push(new Byte(temp[index]));
                temp[index] = temp[count - 1];
                count--;
            }
            //=============================================//
      

  3.   

    srand()和rand()得到随机数,在数组中用随机数抽取扑克牌