mercredi 1 mars 2017

std::find Indexes of multiple same Elements in a Vector C++ [duplicate]

This question already has an answer here:

i need some help with the std::find function.

i have a Vector with some numbers in it...for example :

[5, 3, 5, 7, 5, 5]

now i want to get the indexes of every number 5 in this vector and save it into another vector in the same sequence. For Example :

[0,2,4,5]

Is this possible without using for loops ? because i have vectors which are very long :/ i use this Function to get the Index: std::find(test.begin(), test.end(), 5);

Hope that sb can help me. Thx in advance.

Aucun commentaire:

Enregistrer un commentaire