大家告诉我洗54张扑克牌的程序实现思路好吗? 大家告诉我洗54张扑克牌的程序实现思路好吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 再开54张牌的内存后,随机从原来0-53中随机取一张放到第一,把那张从原来的数组中减掉,然后再从0-52中随机取,放到第二…………建议用vector 好像是我们单位以前的考题嘛。这有个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--; } //=============================================// srand()和rand()得到随机数,在数组中用随机数抽取扑克牌 Error spawning 'vcspawn.exe'. The build could not be performed 哪位大侠能帮帮忙啊!在线等。 这段隐藏CView的边框的代码放在哪里 ? 有人做过SDK 下的mP3播放器嘛? 怎么样从URL中分解出域名来?急,在线等 sunheart(深蓝) 进来 怎样限制窗口的大小? 如何捕获任务栏的鼠标点击消息? 请教vc中msflexgrid控件的使用. 有谁能畅谈一下C++中关于rtti(运行时类型识别)的用处? 为什么不会产生“符号重定义”的错误? 菜鸟关于类声明的问题!在线等
这有个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--;
}
//=============================================//