//宝箱随机道具
struct SItemBoxRandomItem
{
SItemBoxRandomItem(UINT32 id,UINT8 cnt,UINT32 percent)
{
dwItemID = id;
byItemCount = cnt;
dwPercent = percent;
}
UINT32 dwItemID;
UINT32 dwPercent;
UINT8 byItemCount;
};
vector<SItemBoxRandomItem> vecRandomItems;
//percent 累加= 1000
vecRandomItems.push_back(SItemBoxRandomItem(10001,1,1));
vecRandomItems.push_back(SItemBoxRandomItem(10002,3,10));
vecRandomItems.push_back(SItemBoxRandomItem(10003,2,12));
vecRandomItems.push_back(SItemBoxRandomItem(10004,9,15));
vecRandomItems.push_back(SItemBoxRandomItem(10005,3,20));
vecRandomItems.push_back(SItemBoxRandomItem(10006,8,21));
vecRandomItems.push_back(SItemBoxRandomItem(10007,7,31));
vecRandomItems.push_back(SItemBoxRandomItem(10008,4,93));
vecRandomItems.push_back(SItemBoxRandomItem(10009,5,400));
vecRandomItems.push_back(SItemBoxRandomItem(10010,2,400));
//最大掉落个道具
UINT8 iItemCount = 5;
问题:在上述数组中随机抽取5个道具,抽取过的道具不可在抽
UINT32 dwPercent是概率,0~1000以内
比比算法