#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class Pocket
{
int value;
public:
Pocket (int value):value (value)
{
}
int getValue () const
{
return value;
}
bool operator < (const Pocket & _Right) const
{
return value < _Right.value;
}
};
ostream & operator << (ostream & stream, const Pocket & pocket)
{
stream << pocket.getValue ();
return stream;
}
void
printer (Pocket i)
{
cout << i << ", ";
}
int
main ()
{
int mynumbers1[] = { 8, 9, 7, 6 };
int mynumbers2[] = { 4, 1, 4, 5 };
vector < Pocket > v1 (7, 0);
sort (mynumbers2, mynumbers2 + 4);
copy (mynumbers1, mynumbers1 + 3, v1.begin ());
copy (mynumbers2, mynumbers2 + 3, v1.begin () + 3);
sort (mynumbers1, mynumbers1 + 4); //LINE I
inplace_merge (v1.begin (), v1.begin () + 4, v1.end ()); //LINE II
for_each (v1.begin (), v1.end (), printer);
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KCiNpbmNsdWRlIDxpb3N0cmVhbT4KCiNpbmNsdWRlIDxhbGdvcml0aG0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgUG9ja2V0CnsKCiAgaW50IHZhbHVlOwoKcHVibGljOgoKICAgIFBvY2tldCAoaW50IHZhbHVlKTp2YWx1ZSAodmFsdWUpCiAgewogIH0KCiAgaW50IGdldFZhbHVlICgpIGNvbnN0CiAgewogICAgcmV0dXJuIHZhbHVlOwogIH0KCiAgYm9vbCBvcGVyYXRvciA8IChjb25zdCBQb2NrZXQgJiBfUmlnaHQpIGNvbnN0CiAgewogICAgcmV0dXJuIHZhbHVlIDwgX1JpZ2h0LnZhbHVlOwogIH0KCn07Cgogb3N0cmVhbSAmIG9wZXJhdG9yIDw8IChvc3RyZWFtICYgc3RyZWFtLCBjb25zdCBQb2NrZXQgJiBwb2NrZXQpCnsKCiAgc3RyZWFtIDw8IHBvY2tldC5nZXRWYWx1ZSAoKTsKCiAgcmV0dXJuIHN0cmVhbTsKCn0Kdm9pZApwcmludGVyIChQb2NrZXQgaSkKewo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