**[C++] What’s an efficient way to split a vector into multiple smaller vectors?**

Let's suppose that I have the following, vector<int> X = {1,2,3, … , 1000};

I would like to create smaller x vectors that only contain the first 4 digits of the main vector X.

`vector<int> x1 = {1,2,3,4}; vector<int> x2 = {5,6,7,8}; and so on. `

I've found a way to split a vector in to smaller ones but I'm completely stuck on how I can automate this. The command which I'm using to split is the following.

`vector<int> x1(X.begin(), X.begin() + 4); `

Thanks. 🙂

Submitted July 12, 2017 at 08:35AM by VonLuftwaffle

via reddit http://ift.tt/2sPUC5K

### Like this:

Like Loading...

*Related*