#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
std::vector<int> v = {6,3,4,5,6,7,8,6,9};
int pos = -1;
std::vector<int>::iterator it = v.begin();
while((it = std::find(it, v.end(), 6)) != v.end())
{
pos = it - v.begin();
std::cout << "6 is at pos " << pos << std::endl;
++it;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKaW50IG1haW4oKQp7CiAgICBzdGQ6OnZlY3RvcjxpbnQ+IHYgPSB7NiwzLDQsNSw2LDcsOCw2LDl9OwogICAgCiAgICBpbnQgcG9zID0gLTE7CiAgICBzdGQ6OnZlY3RvcjxpbnQ+OjppdGVyYXRvciBpdCA9IHYuYmVnaW4oKTsKICAgIAogICAgd2hpbGUoKGl0ID0gc3RkOjpmaW5kKGl0LCB2LmVuZCgpLCA2KSkgIT0gdi5lbmQoKSkKICAgIHsKICAgICAgICBwb3MgPSBpdCAtIHYuYmVnaW4oKTsKICAgICAgICBzdGQ6OmNvdXQgPDwgIjYgaXMgYXQgcG9zICIgPDwgcG9zIDw8IHN0ZDo6ZW5kbDsKICAgICAgICArK2l0OwogICAgfQp9