[C++] How to repeat an entire vector n times to create one massive vector? via /r/learnprogramming


[C++] How to repeat an entire vector n times to create one massive vector?

Suppose I have a vector<int> x = {1,2,3,4,5,6,7,8,9,10,10,10,10}; and I want to repeat the entire thing 4 times to create vector<int> X = {1,1,1,1,2,2,2,2, … , 10,10,10,10}; How would I go about doing this? Is there a rep() function equivalent from R?

Thanks.

Submitted July 11, 2017 at 10:43PM by VonLuftwaffle
via reddit http://ift.tt/2tLtFkY

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s