Convert vector<int> to integer
问题 I was looking for pre-defined function for converting a vector of integers into a normal integer but i din't find one. vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); Need this: int i=123 //directly converted from vector to int Is there a possible way to achieve this? 回答1: Using C++ 11: reverse(v.begin(), v.end()); int decimal = 1; int total = 0; for (auto& it : v) { total += it * decimal; decimal *= 10; } EDIT: Now it should be the right way. EDIT 2: See DAle's answer for a