```/*****************************************************************
split A into positive and negative elements and print
*****************************************************************/
#include <iostream>
using namespace std;

int main()
{
// read size n, allocate array of n doubles, read values into array
int n;
cin >> n;
double * A = new double[n];
for(int i = 0; i < n; i++)
cin >> A[i];

// Now what?

// Count number of negative and positive entries
int npos = 0, nneg = 0;
for(int i = 0; i < n; i++)
if (A[i] < 0)
nneg++;
else if (A[i] > 0)
npos++;

// Allocate arrays for positive an negative values
double * P = new double[npos];
double * N = new double[nneg];

// put positive values in P and negative values in N
int ipos = 0, ineg = 0;
for(int i = 0; i < n; i++)
if (A[i] < 0)
N[ineg++] = A[i];
else if (A[i] > 0)
P[ipos++] = A[i];

// print!
cout << "negative: ";
for(int i = 0; i < nneg; i++)
cout << N[i] << ' ';
cout << endl;
cout << "positive: ";
for(int i = 0; i < npos; i++)
cout << P[i] << ' ';
cout << endl;

return 0;
}

```