// A Program to extract all odd and even numbers to a seperate arrays
// By DreamVB 12:41 07/10/2016

#include <iostream>
#include <string>

using namespace std;
using std::cout;
using std::endl;

void ShowArrayContents(int *data, int size){
	int i = 0;
	while (i < size){
		if (i < size-1){
			cout << data[i] << ", ";
		}
		i++;
	}
	cout << data[i-1] << endl;
}

bool isOdd(int num){
	return (num % 2 == 1);
}

int main(int argc, char *argv[]){
	
	int numbers[12] = { 1, 2, 3, 4, 5, 10, 16, 20, 41, 65, 7, 9 };
	int NumOdd[12], NumEven[12];
	int src_size = 12;

	int cnt = 0;
	int idx_o = 0;
	int idx_e = 0;

	cout << "Source:" << endl;
	//Print out array numbers
	ShowArrayContents(numbers,12);
	cout << endl;
	cout << "Odd numbers:" << endl;
	

	while (cnt < src_size){
		if (isOdd(numbers[cnt])){
			NumOdd[idx_o] = numbers[cnt];
			idx_o++;
		}
		else{
			NumEven[idx_e] = numbers[cnt];
			idx_e++;
		}
		cnt++;
	}

	//Display odd numbers,
	ShowArrayContents(NumOdd, idx_o);
	cout << endl;
	cout << "Even numbers:" << endl;
	ShowArrayContents(NumEven, idx_e);
	system("pause");
	return 0;
}