洗牌


//混乱扑克
void RandCardList(BYTE cbCardBuffer[], BYTE cbBufferCount)
{
 //混乱准备
 BYTE cbCardData[CountArray(m_cbCardData)];
 CopyMemory(cbCardData,m_cbCardData,sizeof(m_cbCardData));

 //混乱扑克
 BYTE cbRandCount=0,cbPosition=0;
 do
 {
  cbPosition=rand()%(cbBufferCount-cbRandCount);
  cbCardBuffer[cbRandCount++]=cbCardData[cbPosition];
  cbCardData[cbPosition]=cbCardData[cbBufferCount-cbRandCount];
 } while (cbRandCount<cbBufferCount);

 return;
}


//混乱扑克
void RandCardList(BYTE cbCardBuffer[], BYTE cbBufferCount)
{
 //混乱准备
 //混乱扑克
 BYTE cbRandCount=0,cbPosition=0;
 do
 {
  cbPosition=rand()%(cbBufferCount-cbRandCount);
                BYTE tmp;
                tmp=m_cbCardData[cbPosition];                
  m_cbCardData[cbPosition]=m_cbCardData[cbBufferCount-cbRandCount];
                m_cbCardData[cbBufferCount-cbRandCount]=tmp;
                cbRandCount++;               

 } while (cbRandCount<cbBufferCount);

 return;
}
 

你可能感兴趣的:(洗牌)