int CountWayDP(int n) { vector< int > vArr(100, -1); DoCountWayDP(vArr, n); return vArr[n]; }
int main() { int aArr[] = {10, 5, 2, 3, 1, 4, 7, 8, 9, 6}; //MergeSort(aArr, 0, 9); //copy(aArr, &aArr[10], ostream_iterator< int >(cout, " ")); vector< int > vArr(&aArr[0], &aArr[sizeof(aArr) / sizeof(int)]); MergeSort2(vArr, 0, vArr.size() - 1); copy(vArr.begin(), vArr.end(), ostream_iterator< int >(cout, " ")); return 0; }
void PushCommonNotice::handleResponse(CCDictionary *dict) { if (!dict) return; cocos2d::CCDictionary *params=_dict(dict->objectForKey("params")); if (!params) return; string msgId = params->valueForKey("msgId")->getCString(); CCArray* array = dynamic_cast<CCArray*>(params->objectForKey("para")); string tip = _lang(msgId); if (array && array->count()>0) { int num = array->count(); CCString* temp = NULL; std::vector<string> vArr(num,""); for (int i=0; i<num; i++) { temp = dynamic_cast<CCString*>(array->objectAtIndex(i)); if (temp) { vArr[i] = temp->getCString(); } } switch (num) { case 1: tip = _lang_1(msgId,vArr[0].c_str()); break; case 2: tip = _lang_2(msgId,vArr[0].c_str(),vArr[1].c_str()); break; case 3: tip = _lang_3(msgId,vArr[0].c_str(),vArr[1].c_str(),vArr[2].c_str()); break; case 4: tip = _lang_4(msgId,vArr[0].c_str(),vArr[1].c_str(),vArr[2].c_str(),vArr[3].c_str()); break; case 5: tip = _lang_5(msgId,vArr[0].c_str(),vArr[1].c_str(),vArr[2].c_str(),vArr[3].c_str(),vArr[4].c_str()); break; } } if (tip!="") { double worldTime = GlobalData::shared()->getWorldTime(); worldTime *= 1000; worldTime = GlobalData::shared()->renewTime(worldTime); auto time = worldTime+1000*60; CCCommonUtils::flySystemUpdateHint(time, true,tip,FLY_HINT_SYSTEM); } }
void Maze::drawHitBox(sf::RenderTarget& target, sf::RenderStates /* states */) const { sf::VertexArray vArr(sf::Triangles); auto addVertex = [&vArr](float vx, float vy) { sf::Vertex vertex(sf::Vector2f(vx, vy)); vArr.append(vertex); }; for(std::size_t i = 0; i < mazeMap_.size(); ++i) { for(std::size_t j = 0; j < mazeMap_[i].size(); ++j) { TileId id = mazeMap_[i][j]; assert(tileHitBoxesById_.find(id) != tileHitBoxesById_.end()); for(sf::FloatRect v: tileHitBoxesById_.at(id)) { v.top += static_cast<float>(i*tileSize); v.left += static_cast<float>(j*tileSize); //Upper triangle addVertex(v.left , v.top ); addVertex(v.left + v.width, v.top ); addVertex(v.left , v.top + v.height); //Lower triangle addVertex(v.left + v.width, v.top ); addVertex(v.left , v.top + v.height); addVertex(v.left + v.width, v.top + v.height); } } } target.draw(vArr); }