#include
#include
#include
#include
#include
#include
using namespace std;
struct Position {
Position() : position(1) {}
vector zero;
vector positive;
vector negative;
void add(const int value) {
if (!value) zero.push_back(position);
else if (value < 0) negative.push_back(position);
else positive.push_back(position);
++position;
}
void reset() {
position = 1;
}
private:
size_t position;
friend ostream& operator<<(ostream& out, const Position& pos) {
auto iter = ostream_iterator(out, " ");
copy(pos.zero.begin(), pos.zero.end(), iter);
out.put('\n');
copy(pos.positive.begin(), pos.positive.end(), iter);
out.put('\n');
copy(pos.negative.begin(), pos.negative.end(), iter);
return out;
}
};
int main() {
constexpr size_t length = 15;
array sequence{};
constexpr auto left = -10;
constexpr auto right = 10;
uniform_int_distribution<> uid(left, right);
mt19937 gen{ random_device()() };
auto rnd = [&uid, &gen](int& value) { value = uid(gen); };
for_each(sequence.begin(), sequence.end(), rnd);
auto iter = ostream_iterator(cout, " ");
copy(sequence.begin(), sequence.end(), iter);
cout.put('\n');
Position position;
for (auto value : sequence) position.add(value);
cout << position << '\n';
}