# Thread: Combination of point coordinates (recursion help !)

1. ## Combination of point coordinates (recursion help !)

Hello
I could not understand below recursion solution for a combination of upper limit and lower limit point coordinates. How does it progress after print first (1 2 3 4) ? How does ff call stacks work?

Code:
```#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

// pre: a.size() == b.size()
void ff(const vector<int>& a, const vector<int>& b, vector<int>& c) {
if (c.size() == a.size()) {
for (int x: c) cout << setw(4) << x << ' ';
cout << '\n';
}
else {
c.push_back(a[c.size()]);  ff(a, b, c);  c.pop_back();
c.push_back(b[c.size()]);  ff(a, b, c);  c.pop_back();
}
}

void f(const vector<int>& a, const vector<int>& b) {
vector<int> c;
ff(a, b, c);
}

int main() {
vector<int> a{1, 2, 3, 4}, b{10, 20, 30, 40};
f(a, b);``` 2. 3. Originally Posted by Salem Could not get the answer from original, thats why asked here  Popular pages Recent additions #include, a.size, combination, limit, vector 