Recursive function & arrays

I am facing a simple problem, I couldn't figure out the right condition when it comes to check the value of index 0

Here is the question

Write a recursive function named SeparateNumbers which takes as parameters an array of integers and the array size. The function should print out all the positive numbers and then all the negative numbers. The function should NOT print any of the zeros in the array. The prototype for the function is:
void SeparateNumbers (int array[], int size);
Example
If the array contains the following values before calling the function SeparateNumbers: 1 0 4 -3 5 2 -7 2
The function SeparateNumbers should display the following output:
2 2 5 4 1 -3 -7


My solution
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;
void SeparateNumbers (int Array[], int size);
int main()
{
	int size, Arr[100];
	cout<<"Enter the size of the array: ";
	cin>>size;

	cout<<"Enter the number in the array:-"<<endl;
	for(int i=0; i<size; i++)
		cin>>Arr[i];

	SeparateNumbers (Arr, size);
	cout<<endl;

	system("pause");
	return 0;
}

void SeparateNumbers (int Array[], int size)
{
	if(size >= 0)
	{
		if(Array[size-1] > 0)
		{
			cout<<Array[size-1]<<" ";
			SeparateNumbers(Array, size-1);
		}
		else if(Array[size-1] < 0)
		{
			SeparateNumbers(Array, size-1);
			cout<<Array[size-1]<<" ";
		}
	}
}
You can write the condition the following way

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void SeparateNumbers (int Array[], int size)
{
	if( size > 0 )
	{
		if(Array[size-1] > 0)
		{
			cout<<Array[size-1]<<" ";
			SeparateNumbers( Array, size-1);
		}
		else if(Array[size-1] < 0)
		{
			SeparateNumbers(Array, size-1);
			cout<<Array[size-1]<<" ";
		}
	}
}


But in any case the result will be incorrect because the order of elements will be broken.
Consider for example array

{ 1, 2 )

It will be printed as

2, 1
Topic archived. No new replies allowed.