Daehyun
11/7/2018 - 1:18 PM

nested_loop.cpp

#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    std::vector<std::vector<int>> arrs{
        {0, 1, 2},
        {3, 4, 5, 6},
        {7, 8}
    };

    int n = 1;
    for (const auto &arr : arrs) {
        n *= arr.size();
    }

    for (int i = 0; i < n; i++) {
        auto tmp = i;
        std::vector<int> idx;
        for (auto const &arr : arrs) {
            auto j = tmp % arr.size();
            tmp /= arr.size();
            // Go your code here
            std::cout << arr[j] << " ";
        }
        std::cout << std::endl;
    }
    return 0;
}