-
randomly remove elements
It seems more difficult than i thought...
Ok,another question..Suppose that i have a set( vector) with n elements. How can i remove randomly let's say half of them??
All the remove algorithms of the C++ satisfy a criterion. I don't need one. Just randomly remove some elements.
Thanx
-
I would either generate a random number between 0 and size() - 1 and do this for half of the elements or simply call random_shuffle() and delete size() / 2 elements of the vector. I would probably opt for the latter option.
Edit: Oh, didn't see the other thread. Oh well, a mod can move my post to the other thread ?
-
Ok..thanx a lot.
Yes, by mistake i double posted