Base conversion example:
If the number 17 was to be converted into base 5
17/3 = 5R2
5/3= 1R2
2/3 = 0R1
The value in the new base = All the remainders in reverse order
In this case Remainders = 221
In reverse order = 122
for( int i = 0; i< list.size(); i++) {
std::vector<int> tmp; // create empty vector
tmp[i] = list[i][0]; // assign to element i, even though tmp has no elements
Furthermore, you do read integer list[i][0] without checking. The list[i] could be an empty vector.
Do consider:
1 2 3 4 5 6 7 8 9
int main(){
std::vector<std::vector<int>> list;
generate_list( list , 6, 4 );
for ( constauto& row : list ) {
for ( auto x : row ) {
std::cout << x << '\n';
}
}
}
Or (if you need to a copy):
1 2 3 4 5 6 7 8 9 10
int main(){
std::vector<std::vector<int>> list;
generate_list( list , 6, 4 );
for ( size_t i = 0; i< list.size(); ++i ) {
std::vector<int> row = list[i];
for ( auto x : row ) {
std::cout << x << '\n';
}
}
}