lua数组进入c数组
发布时间:2020-12-14 21:44:32 所属栏目:大数据 来源:网络整理
导读:local pricetagColors = { [3242] = {255,255},[6712] = {255,255,0} } function getPricetagColor(itemnumber) local r,g,b = 0,0 if pricetagColors[itemnumber] then r,b = pricetagColors[itemnumber][1],pricetagColors[itemnumber][2],pricetagColors[
local pricetagColors = { [3242] = {255,255},[6712] = {255,255,0} } function getPricetagColor(itemnumber) local r,g,b = 0,0 if pricetagColors[itemnumber] then r,b = pricetagColors[itemnumber][1],pricetagColors[itemnumber][2],pricetagColors[itemnumber[3] end return {r,b} end 好吧,所以我正试着一步一步进入C. 解决方法
看起来你在问题中所拥有的东西等同于std :: map< int,std :: array< int,3>>.
std::map<int,std::array<int,3>> pricetagColors; pricetagColors[3242] = {255,255}; pricetagColors[6712] = {255,0}; int itemnumber = 3242,r,b; if (pricetagColors.find(itemnumber) != pricetagColors.end()) { r = pricetagColors[itemnumber][0]; g = pricetagColors[itemnumber][1]; b = pricetagColors[itemnumber][2]; //Note that the comma operator could be used here,//but it isn't really an idiomatic C++ use } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |