All pastes #1049970 Raw Edit

Stuff

public cpp v1 · immutable
#1049970 ·published 2008-06-18 08:56 UTC
rendered paste body
#include <iostream>int main(){  // think about initialisation for yourself	int a[] = {-3, -4, 5, -7, -65, 5, -8, 9, 7, 12};	int i;	int neg=0;	for(i=0;i<10;i++)	{		if(a[i]<0)neg++;	}	int *b,*c;	if(neg==0)	{		b=new int[10];		c=NULL;	}	else if(neg==10)	{		b=NULL;		c=new int[10];	}	else	{		b=new int[10-neg];		c=new int[neg];	}	int bb=0;	int cc=0;	for(i=0;i<10;i++)	{		if(a[i]<0)		{			c[cc++]=a[i];		}		else		{			b[bb++]=a[i];		}	}// int* neg = split(a, size);  std::cout << "Positive: ";  if(b!=NULL)for (i=0;i<10-neg;i++)std::cout << b[i] << ' ';  std::cout << "\nNegative: ";  if(c!=NULL)for (i=0;i<neg;i++)std::cout << c[i] << ' ';  std::cout << std::endl;  if(b!=NULL)delete b;  if(c!=NULL)delete c;  getchar();  return 0;}