const BYTE CGameLogic::m_cbCardData[108]=
{
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D, //方块 A - K
0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D, //梅花 A - K
0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D, //红桃 A - K
0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D, //黑桃 A - K
0x4E,0x4F,
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D, //方块 A - K
0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D, //梅花 A - K
0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D, //红桃 A - K
0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D, //黑桃 A - K
0x4E,0x4F,
}
//混乱扑克
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;
}
BYTE cbRandCard[108];
BYTE m_cbHandCardData[4][27];
RandCardList(cbRandCard,CountArray(cbRandCard));
for (WORD i=0;i<4;i++)
{m_cbHandCardCount[i]=MAX_COUNT;
CopyMemory(&m_cbHandCardData[i],&cbRandCard[i*m_cbHandCardCount[i]],sizeof(BYTE)*m_cbHandCardCount[i]);
}
哪位C++高手能详细分析一下CopyMemory()函数是怎样把数组cbRandCard[]的内容复制到m_cbHandCardData[]数组中的,当i=0时,m_cbHandCardData[0][14]的所有元素不都为0吗?
可是我不是想知道函数CopyMemory()的作用,我是想知道当i=0,1,2,3,时cbRandCard[i*m_cbHandCardCount[i]以及m_cbHandCardData[i]的变化情况
哈士奇WWW
相关分类