Hello,
vector <int>my_array
my_array is 32 in size.
The contents of my_array is:
11110000011111110000011111….111
I want to know the 4 index positions of '0'.
How do I do it?
Thanks,
codeguy
Hello,
vector <int>my_array
my_array is 32 in size.
The contents of my_array is:
11110000011111110000011111….111
I want to know the 4 index positions of '0'.
How do I do it?
Thanks,
codeguy
What do you mean by the "4 index positions of '0'"?I want to know the 4 index positions of '0'.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I meant the four in color:
11110000011111110000011111….111
-codeguy
Iterate through the vector. When the number changes from 1 to 0 or from 0 to 1, make a note.
I guess you'll have to loop over the entire vector, keep a count of (consequtive?) 0-s and then decide whether a particular 0 is the one that you are interested in.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
There's also the std::find() function in the <algorithm> header, but then you'll have to convert the iterator it returns to an index (try the std::distance() function in <iterator>).
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"