I need some help

I would like to create 250 vectors using a for{} loop, having the name changing by i.Exemple i want to calle it v'i'. So if i goes from 0 to 3, i should have v0 v1 v2 v3.


Pretty sure you cant do that

But I think you can create a multidimensional vector instead.
Last edited on
However, you can have "names" v[0], v[1], v[2] and v[3].
I am quite new to C++, and i have a huge vector (37000 values) wich i need to devide into 250 smaller vectors. I really have no idea how i can do that. Is there any type of task that can dvide a vector?
That sounds like a hell of a useless task. Either way, you can use multidimensional vectors. Either look up some info about it on google, or watch this video, I think he explains it atleast decent.

https://www.youtube.com/watch?v=lnqjNYd_hho&ab_channel=CodingMadeEasy
More context would help.

Genuinely divide, or would pretending be sufficient?
No i am obliged to divide it :(
Well, there is always the range-based assignment: http://www.cplusplus.com/reference/vector/vector/assign/

1
2
3
4
5
6
7
8
9
10
constexpr size_t Subs { 7 };
std::array<std::vector<Foo>,Subs> family;

size_t member = 0;
while ( member < Subs ) {
  auto perMember { huge.size() / Subs }; // Or is it? Think.
  auto pos { huge.begin() + member * perMember };
  family[ member ].assign( pos, pos + perMember );
  ++member;
}
Topic archived. No new replies allowed.