#include #include //for ostream_iterator #include #include #include using namespace std; int main() { const int a[] = {10, 10, 10, 20, 30, 30, 50}; //must be sorted const size_t n = sizeof a / sizeof a[0]; const int *const p = upper_bound(a, a + n, a[0]); vector v; copy(a, p, back_inserter(v)); copy(v.begin(), v.end(), ostream_iterator(cout, "\n")); return EXIT_SUCCESS; }